cursor = arangoDB.db(databaseName).query(aqlQuery, bindVars, null, VPackSlice.class); while (cursor.hasNext()) { VPackSlice aDocument = cursor.next();
@Override public long count(String documentCollection) { Objects.requireNonNull(documentCollection, "document collection is required"); String aql = "RETURN LENGTH(" + documentCollection + ")"; ArangoCursor<Object> query = arangoDB.db(database).query(aql, Collections.emptyMap(), null, Object.class); return StreamSupport.stream(query.spliterator(), false).findFirst().map(Long.class::cast).orElse(0L); }
@Override public List<DocumentEntity> aql(String query, Map<String, Object> values) throws NullPointerException { requireNonNull(query, "query is required"); requireNonNull(values, "values is required"); ArangoCursor<BaseDocument> result = arangoDB.db(database).query(query, values, null, BaseDocument.class); return StreamSupport.stream(result.spliterator(), false) .map(ArangoDBUtil::toEntity) .collect(toList()); }
/** * Execute AQL query. * * @param <T> the generic type of the returned values * @param query the query string * @param bindVars the value of the bind parameters * @param aqlQueryOptions the aql query options * @param type the type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map) * @return the cursor result * @throws ArangoDBGraphException if executing the query raised an exception */ public <T> ArangoCursor<T> executeAqlQuery( String query, Map<String, Object> bindVars, AqlQueryOptions aqlQueryOptions, final Class<T> type) throws ArangoDBGraphException { logger.debug("Executing AQL query ({}) against db, with bind vars: {}", query, bindVars); try { return db.query(query, bindVars, aqlQueryOptions, type); } catch (ArangoDBException e) { logger.error("Error executing query", e); throw ArangoDBExceptions.getArangoDBException(e); } }
@Override public List<DocumentEntity> select(DocumentQuery query) throws NullPointerException { requireNonNull(query, "query is required"); AQLQueryResult result = QueryAQLConverter.select(query); ArangoCursor<BaseDocument> documents = arangoDB.db(database).query(result.getQuery(), result.getValues(), null, BaseDocument.class); return StreamSupport.stream(documents.spliterator(), false) .map(ArangoDBUtil::toEntity) .collect(toList()); }
@Override public <T> ArangoCursor<T> query( final String query, final Map<String, Object> bindVars, final AqlQueryOptions options, final Class<T> entityClass) throws DataAccessException { return db().query(query, bindVars == null ? null : prepareBindVars(bindVars), options, entityClass); }
@Override public <T> ArangoCursor<T> query( final String query, final Map<String, Object> bindVars, final AqlQueryOptions options, final Class<T> entityClass) throws DataAccessException { return db().query(query, bindVars == null ? null : prepareBindVars(bindVars), options, entityClass); }
@Override public void delete(DocumentDeleteQuery query) { requireNonNull(query, "query is required"); if (checkCondition(query.getCondition())) { return; } AQLQueryResult delete = QueryAQLConverter.delete(query); arangoDB.db(database).query(delete.getQuery(), delete.getValues(), null, BaseDocument.class); }