Search in sources :

Example 1 with FindAndDeleteOptions

use of dev.morphia.query.FindAndDeleteOptions in project morphia by mongodb.

the class TestDatastore method testFindAndDeleteWithCollation.

@Test
public void testFindAndDeleteWithCollation() {
    getDs().save(asList(new FacebookUser(1, "John Doe"), new FacebookUser(2, "john doe")));
    Query<FacebookUser> query = getDs().find(FacebookUser.class).filter(eq("username", "john doe"));
    assertNotNull(query.findAndDelete());
    assertNull(query.findAndDelete());
    FindAndDeleteOptions options = new FindAndDeleteOptions().collation(Collation.builder().locale("en").collationStrength(SECONDARY).build());
    assertNotNull(query.findAndDelete(options));
    assertNull(query.iterator().tryNext());
}
Also used : FindAndDeleteOptions(dev.morphia.query.FindAndDeleteOptions) FacebookUser(dev.morphia.test.models.FacebookUser) Test(org.testng.annotations.Test)

Aggregations

FindAndDeleteOptions (dev.morphia.query.FindAndDeleteOptions)1 FacebookUser (dev.morphia.test.models.FacebookUser)1 Test (org.testng.annotations.Test)1