use of jakarta.nosql.Params in project jnosql-diana by eclipse.
the class UpdateQueryParser method query.
Stream<DocumentEntity> query(String query, DocumentCollectionManager collectionManager, DocumentObserverParser observer) {
UpdateQuery updateQuery = supplier.apply(query);
Params params = Params.newParams();
DocumentEntity entity = getEntity(params, updateQuery, observer);
if (params.isNotEmpty()) {
throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
}
return Stream.of(collectionManager.update(entity));
}
use of jakarta.nosql.Params in project jnosql-diana by eclipse.
the class UpdateQueryParser method prepare.
DocumentPreparedStatement prepare(String query, DocumentCollectionManager collectionManager, DocumentObserverParser observer) {
Params params = Params.newParams();
UpdateQuery updateQuery = supplier.apply(query);
DocumentEntity entity = getEntity(params, updateQuery, observer);
return DefaultDocumentPreparedStatement.update(entity, params, query, collectionManager);
}
use of jakarta.nosql.Params in project jnosql-diana by eclipse.
the class DocumentParamsTest method shouldAddParameter.
@Test
public void shouldAddParameter() {
Params params = Params.newParams();
Value name = params.add("name");
assertNotNull(name);
MatcherAssert.<List<String>>assertThat(params.getParametersNames(), containsInAnyOrder("name"));
}
use of jakarta.nosql.Params in project jnosql-diana by eclipse.
the class DocumentParamsTest method shouldSetParameter.
@Test
public void shouldSetParameter() {
Params params = Params.newParams();
Value name = params.add("name");
Document document = Document.of("name", name);
params.bind("name", "Ada Lovelace");
assertEquals("Ada Lovelace", document.get());
params.bind("name", "Diana");
assertEquals("Diana", document.get());
}
use of jakarta.nosql.Params in project jnosql-diana by eclipse.
the class InsertQueryParser method prepare.
DocumentPreparedStatement prepare(String query, DocumentCollectionManager collectionManager, DocumentObserverParser observer) {
InsertQuery insertQuery = insertQueryProvider.apply(query);
String collection = observer.fireEntity(insertQuery.getEntity());
Params params = Params.newParams();
Optional<Duration> ttl = insertQuery.getTtl();
DocumentEntity entity = getEntity(insertQuery, collection, params, observer);
return DefaultDocumentPreparedStatement.insert(entity, params, query, ttl.orElse(null), collectionManager);
}
Aggregations