use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class MongoDBDocumentCollectionManagerTest method shouldRemoveEntity.
@Test
public void shouldRemoveEntity() {
DocumentEntity documentEntity = entityManager.insert(getEntity());
Optional<Document> id = documentEntity.find("_id");
DocumentQuery query = select().from(COLLECTION_NAME).where("_id").eq(id.get().get()).build();
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).where("_id").eq(id.get().get()).build();
entityManager.delete(deleteQuery);
assertTrue(entityManager.select(query).collect(Collectors.toList()).isEmpty());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class DefaultCouchbaseDocumentCollectionManager method delete.
@Override
public void delete(DocumentDeleteQuery query) {
QueryConverter.QueryConverterResult delete = QueryConverter.delete(query, database);
if (nonNull(delete.getStatement())) {
ParameterizedN1qlQuery n1qlQuery = N1qlQuery.parameterized(delete.getStatement(), delete.getParams());
bucket.query(n1qlQuery);
}
if (!delete.getKeys().isEmpty()) {
delete.getKeys().stream().map(s -> getPrefix(query.getDocumentCollection(), s)).forEach(bucket::remove);
}
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class ElasticsearchDocumentCollectionManagerTest method setUp.
@BeforeEach
public void setUp() {
ElasticsearchDocumentCollectionManagerFactory managerFactory = ElasticsearchDocumentCollectionManagerFactorySupplier.INSTANCE.get();
entityManager = managerFactory.get(DocumentEntityGerator.INDEX);
DocumentDeleteQuery deleteQuery = DocumentDeleteQuery.delete().from("person").build();
entityManager.delete(deleteQuery);
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class DefaultSolrDocumentCollectionManagerTest method shouldExecuteNativeQueryParamsReplaceAll.
@Test
public void shouldExecuteNativeQueryParamsReplaceAll() {
entityManager.insert(getEntitiesWithValues());
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).build();
entityManager.delete(deleteQuery);
entityManager.insert(getEntitiesWithValues());
Map<String, Object> params = new HashMap<>();
params.put("age", 22);
List<DocumentEntity> entitiesFound = entityManager.solr("age:@age AND age:@age", params);
assertEquals(1, entitiesFound.size());
}
use of jakarta.nosql.document.DocumentDeleteQuery in project jnosql-diana-driver by eclipse.
the class DefaultSolrDocumentCollectionManagerTest method shouldFindDocumentStart.
@Test
public void shouldFindDocumentStart() {
DocumentDeleteQuery deleteQuery = delete().from(COLLECTION_NAME).build();
entityManager.delete(deleteQuery);
Iterable<DocumentEntity> entitiesSaved = entityManager.insert(getEntitiesWithValues());
List<DocumentEntity> entities = StreamSupport.stream(entitiesSaved.spliterator(), false).collect(Collectors.toList());
DocumentQuery query = select().from(COLLECTION_NAME).where("age").gt(22).and("type").eq("V").skip(1L).build();
List<DocumentEntity> entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertEquals(2, entitiesFound.size());
assertThat(entitiesFound, not(contains(entities.get(0))));
query = select().from(COLLECTION_NAME).where("age").gt(22).and("type").eq("V").skip(3L).build();
entitiesFound = entityManager.select(query).collect(Collectors.toList());
assertTrue(entitiesFound.isEmpty());
}
Aggregations