8000 Add convenience methods · MladenMitev/arangodb-java-driver@1beae1d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1beae1d

Browse files
author
mpv1989
committed
Add convenience methods
- added convenience method `ArangoDatabase#query(String, Class)` - added convenience method `ArangoDatabase#query(String, Map<String, Object>, Class)`
1 parent 7558e13 commit 1beae1d

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- added convenience method `ArangoDatabase#query(String, Class)`
12+
- added convenience method `ArangoDatabase#query(String, Map<String, Object>, Class)`
13+
914
### Fixed
1015

1116
- fixed `ArangoCollection#rename(String)`

src/main/java/com/arangodb/ArangoDatabase.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,38 @@ public interface ArangoDatabase {
296296
<T> ArangoCursor<T> query(String query, Map<String, Object> bindVars, AqlQueryOptions options, Class<T> type)
297297
throws ArangoDBException;
298298

299+
/**
300+
* Performs a database query using the given {@code query} and {@code bindVars}, then returns a new
301+
* {@code ArangoCursor} instance for the result list.
302+
*
303+
* @see <a href="https://docs.arangodb.com/current/HTTP/AqlQueryCursor/AccessingCursors.html#create-cursor">API
304+
* Documentation</a>
305+
* @param query
306+
* An AQL query string
307+
* @param bindVars
308+
* key/value pairs defining the variables to bind the query to
309+
* @param type
310+
* The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
311+
* @return cursor of the results
312+
* @throws ArangoDBException
313+
*/
314+
<T> ArangoCursor<T> query(String query, Map<String, Object> bindVars, Class<T> type) throws ArangoDBException;
315+
316+
/**
317+
* Performs a database query using the given {@code query}, then returns a new {@code ArangoCursor} instance for the
318+
* result list.
319+
*
320+
* @see <a href="https://docs.arangodb.com/current/HTTP/AqlQueryCursor/AccessingCursors.html#create-cursor">API
321+
* Documentation</a>
322+
* @param query
323+
* An AQL query string
324+
* @param type
325+
* The type of the result (POJO class, VPackSlice, String for Json, or Collection/List/Map)
326+
* @return cursor of the results
327+
* @throws ArangoDBException
328+
*/
329+
<T> ArangoCursor<T> query(String query, Class<T> type) throws ArangoDBException;
330+
299331
/**
300332
* Return an cursor from the given cursor-ID if still existing
301333
*

src/main/java/com/arangodb/internal/ArangoDatabaseImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ public <T> ArangoCursor<T> query(
192192
return createCursor(result, type, hostHandle);
193193
}
194194

195+
@Override
196+
public <T> ArangoCursor<T> query(final String query, final Map<String, Object> bindVars, final Class<T> type)
197+
throws ArangoDBException {
198+
return query(query, bindVars, null, type);
199+
}
200+
201+
@Override
202+
public <T> ArangoCursor<T> query(final String query, final Class<T> type) throws ArangoDBException {
203+
return query(query, null, null, type);
204+
}
205+
195206
@Override
196207
public <T> ArangoCursor<T> cursor(final String cursorId, final Class<T> type) throws ArangoDBException {
197208
final HostHandle hostHandle = new HostHandle();

0 commit comments

Comments
 (0)
0