use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerTest method shouldQueryIn.
@Test
public void shouldQueryIn() {
entityManager.insert(getEntities());
DocumentQuery query = select().from(COLLECTION_NAME).where("city").in(asList("Salvador", "Assis")).build();
assertTrue(entityManager.select(query).size() == 2);
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where("city").in(asList("Salvador", "Assis", "Sao Paulo")).build();
entityManager.delete(deleteQuery);
assertTrue(entityManager.select(query).isEmpty());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerTest method shouldQueryOr.
@Test
public void shouldQueryOr() {
DocumentEntity entity = getEntity();
entity.add(Document.of("age", 24));
entityManager.insert(entity);
DocumentQuery query = select().from(COLLECTION_NAME).where("name").eq("Poliana").or("age").gte(10).build();
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where("name").eq("Poliana").or("age").gte(10).build();
assertFalse(entityManager.select(query).isEmpty());
entityManager.delete(deleteQuery);
assertTrue(entityManager.select(query).isEmpty());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerTest method removePersons.
@AfterEach
void removePersons() {
DocumentDeleteQuery query = delete().from(COLLECTION_NAME).build();
entityManager.delete(query);
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerTest method shouldQueryAnd.
@Test
public void shouldQueryAnd() {
DocumentEntity entity = getEntity();
entity.add(Document.of("age", 24));
entityManager.insert(entity);
DocumentQuery query = select().from(COLLECTION_NAME).where("name").eq("Poliana").and("age").gte(10).build();
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where("name").eq("Poliana").and("age").gte(10).build();
assertFalse(entityManager.select(query).isEmpty());
entityManager.delete(deleteQuery);
assertTrue(entityManager.select(query).isEmpty());
}
use of org.jnosql.diana.api.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerTest method shouldLiveDeleteCallback.
@Test
public void shouldLiveDeleteCallback() {
AtomicBoolean condition = new AtomicBoolean(false);
OrientDBLiveDeleteCallback<DocumentEntity> callback = d -> condition.set(true);
DocumentEntity entity = entityManager.insert(getEntity());
Document id = entity.find(OrientDBConverter.RID_FIELD).get();
DocumentQuery query = select().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
entityManager.live(query, OrientDBLiveCallbackBuilder.builder().onDelete(callback).build());
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where(id.getName()).eq(id.get()).build();
entityManager.delete(deleteQuery);
await().untilTrue(condition);
}
Aggregations