mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into devel
This commit is contained in:
commit
c8660c967c
|
@ -136,10 +136,10 @@ db.listCollections().then(function (collections) {
|
|||
</script>
|
||||
```
|
||||
|
||||
If you are targetting browsers older than Internet Explorer 11 you
|
||||
may want to use [babel](https://babeljs.io)
|
||||
with a [polyfill](https://babeljs.io/docs/usage/polyfill)
|
||||
to provide missing functionality needed to use arangojs.
|
||||
If you are targetting browsers older than Internet Explorer 11 you may want to
|
||||
use [babel](https://babeljs.io) with a
|
||||
[polyfill](https://babeljs.io/docs/usage/polyfill) to provide missing
|
||||
functionality needed to use arangojs.
|
||||
|
||||
When loading the browser build with a script tag make sure to load the polyfill first:
|
||||
|
||||
|
@ -213,8 +213,7 @@ AQL queries without making your code vulnerable to injection attacks.
|
|||
## Error responses
|
||||
|
||||
If arangojs encounters an API error, it will throw an _ArangoError_ with an
|
||||
[_errorNum_ as defined in the ArangoDB documentation](../../..//Manual/Appendix/ErrorCodes.html)
|
||||
as well as a _code_ and _statusCode_ property indicating the intended and actual HTTP status code of the response.
|
||||
[_errorNum_ as defined in the ArangoDB documentation](../../..//Manual/Appendix/ErrorCodes.html) as well as a _code_ and _statusCode_ property indicating the intended and actual HTTP status code of the response.
|
||||
|
||||
For any other error responses (4xx/5xx status code), it will throw an
|
||||
_HttpError_ error with the status code indicated by the _code_ and _statusCode_ properties.
|
||||
|
|
|
@ -13,7 +13,7 @@ then returns the server response.
|
|||
|
||||
**Arguments**
|
||||
|
||||
* **properties**: `Object` (optional)
|
||||
- **properties**: `Object` (optional)
|
||||
|
||||
For more information on the _properties_ object, see
|
||||
[the HTTP API documentation for creating collections](../../../..//HTTP/Collection/Creating.html).
|
||||
|
@ -22,9 +22,9 @@ then returns the server response.
|
|||
|
||||
```js
|
||||
const db = new Database();
|
||||
const collection = db.collection('potatos');
|
||||
const collection = db.collection('potatoes');
|
||||
await collection.create()
|
||||
// the document collection "potatos" now exists
|
||||
// the document collection "potatoes" now exists
|
||||
|
||||
// -- or --
|
||||
|
||||
|
@ -43,7 +43,7 @@ Tells the server to load the collection into memory.
|
|||
|
||||
**Arguments**
|
||||
|
||||
* **count**: `boolean` (Default: `true`)
|
||||
- **count**: `boolean` (Default: `true`)
|
||||
|
||||
If set to `false`, the return value will not include the number of documents
|
||||
in the collection (which may speed up the process).
|
||||
|
@ -80,7 +80,7 @@ Replaces the properties of the collection.
|
|||
|
||||
**Arguments**
|
||||
|
||||
* **properties**: `Object`
|
||||
- **properties**: `Object`
|
||||
|
||||
For information on the _properties_ argument see
|
||||
[the HTTP API for modifying collections](../../../..//HTTP/Collection/Modifying.html).
|
||||
|
@ -152,11 +152,11 @@ Deletes the collection from the database.
|
|||
|
||||
**Arguments**
|
||||
|
||||
* **properties**: `Object` (optional)
|
||||
- **properties**: `Object` (optional)
|
||||
|
||||
An object with the following properties:
|
||||
|
||||
* **isSystem**: `Boolean` (Default: `false`)
|
||||
- **isSystem**: `Boolean` (Default: `false`)
|
||||
|
||||
Whether the collection should be dropped even if it is a system collection.
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ Returns a _DocumentCollection_ instance for the given collection name.
|
|||
|
||||
**Arguments**
|
||||
|
||||
* **collectionName**: `string`
|
||||
- **collectionName**: `string`
|
||||
|
||||
Name of the edge collection.
|
||||
|
||||
|
@ -20,7 +20,7 @@ Returns a _DocumentCollection_ instance for the given collection name.
|
|||
|
||||
```js
|
||||
const db = new Database();
|
||||
const collection = db.collection("potatos");
|
||||
const collection = db.collection("potatoes");
|
||||
```
|
||||
|
||||
## database.edgeCollection
|
||||
|
@ -31,7 +31,7 @@ Returns an _EdgeCollection_ instance for the given collection name.
|
|||
|
||||
**Arguments**
|
||||
|
||||
* **collectionName**: `string`
|
||||
- **collectionName**: `string`
|
||||
|
||||
Name of the edge collection.
|
||||
|
||||
|
@ -39,7 +39,7 @@ Returns an _EdgeCollection_ instance for the given collection name.
|
|||
|
||||
```js
|
||||
const db = new Database();
|
||||
const collection = db.edgeCollection("potatos");
|
||||
const collection = db.edgeCollection("potatoes");
|
||||
```
|
||||
|
||||
## database.listCollections
|
||||
|
@ -51,7 +51,7 @@ descriptions.
|
|||
|
||||
**Arguments**
|
||||
|
||||
* **excludeSystem**: `boolean` (Default: `true`)
|
||||
- **excludeSystem**: `boolean` (Default: `true`)
|
||||
|
||||
Whether system collections should be excluded.
|
||||
|
||||
|
@ -80,7 +80,7 @@ _DocumentCollection_ and _EdgeCollection_ instances for the collections.
|
|||
|
||||
**Arguments**
|
||||
|
||||
* **excludeSystem**: `boolean` (Default: `true`)
|
||||
- **excludeSystem**: `boolean` (Default: `true`)
|
||||
|
||||
Whether system collections should be excluded.
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@ If _config_ is a string, it will be interpreted as _config.url_.
|
|||
|
||||
Base URL of the ArangoDB server or list of server URLs.
|
||||
|
||||
When working with a cluster or a single server with leader/follower failover,
|
||||
[the method `db.acquireHostList`](DatabaseManipulation.md#databaseacquirehostlist)
|
||||
can be used to automatically pick up additional coordinators/followers at
|
||||
any point.
|
||||
|
||||
**Note**: As of arangojs 6.0.0 it is no longer possible to pass
|
||||
the username or password from the URL.
|
||||
|
||||
|
@ -105,6 +110,30 @@ If _config_ is a string, it will be interpreted as _config.url_.
|
|||
|
||||
- `ROUND_ROBIN`: Every sequential request uses the next URL in the list.
|
||||
|
||||
- **maxRetries**: `number` or `false` (Default: `0`)
|
||||
|
||||
Determines the behavior when a request fails because the underlying
|
||||
connection to the server could not be opened
|
||||
(i.e. [`ECONNREFUSED` in Node.js](https://nodejs.org/api/errors.html#errors_common_system_errors)):
|
||||
|
||||
- `false`: the request fails immediately.
|
||||
|
||||
- `0`: the request is retried until a server can be reached but only a
|
||||
total number of times matching the number of known servers (including
|
||||
the initial failed request).
|
||||
|
||||
- any other number: the request is retried until a server can be reached
|
||||
the request has been retried a total of `maxRetries` number of times
|
||||
(not including the initial failed request).
|
||||
|
||||
When working with a single server without leader/follower failover, the
|
||||
retries (if any) will be made to the same server.
|
||||
|
||||
This setting currently has no effect when using arangojs in a browser.
|
||||
|
||||
**Note**: Requests bound to a specific server (e.g. fetching query results)
|
||||
will never be retried automatically and ignore this setting.
|
||||
|
||||
## database.close
|
||||
|
||||
`database.close(): void`
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/arangodbjs.git / docs/Drivers/ -->
|
||||
# Accessing views
|
||||
|
||||
These functions implement the
|
||||
[HTTP API for accessing views](../../../..//HTTP/Views/Getting.html).
|
||||
|
||||
## database.arangoSearchView
|
||||
|
||||
`database.arangoSearchView(viewName): ArangoSearchView`
|
||||
|
||||
Returns a _ArangoSearchView_ instance for the given view name.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **viewName**: `string`
|
||||
|
||||
Name of the arangosearch view.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
const view = db.arangoSearchView("potatoes");
|
||||
```
|
||||
|
||||
## database.listViews
|
||||
|
||||
`async database.listViews(): Array<Object>`
|
||||
|
||||
Fetches all views from the database and returns an array of view
|
||||
descriptions.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
|
||||
const views = await db.listViews();
|
||||
// views is an array of view descriptions
|
||||
```
|
||||
|
||||
## database.views
|
||||
|
||||
`async database.views([excludeSystem]): Array<View>`
|
||||
|
||||
Fetches all views from the database and returns an array of
|
||||
_ArangoSearchView_ instances for the views.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
|
||||
const views = await db.views()
|
||||
// views is an array of ArangoSearchView instances
|
||||
```
|
|
@ -4,6 +4,7 @@
|
|||
- [Database](Database/README.md)
|
||||
- [Database Manipulation](Database/DatabaseManipulation.md)
|
||||
- [Collection Access](Database/CollectionAccess.md)
|
||||
- [View Access](Database/ViewAccess.md)
|
||||
- [Queries](Database/Queries.md)
|
||||
- [AQL User Functions](Database/AqlUserFunctions.md)
|
||||
- [Transactions](Database/Transactions.md)
|
||||
|
@ -18,6 +19,7 @@
|
|||
- [Indexes](Collection/Indexes.md)
|
||||
- [Simple Queries](Collection/SimpleQueries.md)
|
||||
- [Bulk Import](Collection/BulkImport.md)
|
||||
- [View Manipulation](ViewManipulation.md)
|
||||
- [Cursor](Cursor.md)
|
||||
- [Graph](Graph/README.md)
|
||||
- [Vertices](Graph/Vertices.md)
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/arangodbjs.git / docs/Drivers/ -->
|
||||
# View API
|
||||
|
||||
These functions implement the
|
||||
[HTTP API for manipulating views](../../..//HTTP/Views/index.html).
|
||||
|
||||
## view.exists
|
||||
|
||||
`async view.exists(): boolean`
|
||||
|
||||
Checks whether the view exists.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
const view = db.arangoSearchView('some-view');
|
||||
const result = await view.exists();
|
||||
// result indicates whether the view exists
|
||||
```
|
||||
|
||||
### view.get
|
||||
|
||||
`async view.get(): Object`
|
||||
|
||||
Retrieves general information about the view.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
const view = db.arangoSearchView('some-view');
|
||||
const data = await view.get();
|
||||
// data contains general information about the view
|
||||
```
|
||||
|
||||
### view.properties
|
||||
|
||||
`async view.properties(): Object`
|
||||
|
||||
Retrieves the view's properties.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
const view = db.arangoSearchView('some-view');
|
||||
const data = await view.properties();
|
||||
// data contains the view's properties
|
||||
```
|
||||
|
||||
## view.create
|
||||
|
||||
`async view.create([properties]): Object`
|
||||
|
||||
Creates a view with the given _properties_ for this view's name,
|
||||
then returns the server response.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **properties**: `Object` (optional)
|
||||
|
||||
For more information on the _properties_ object, see
|
||||
[the HTTP API documentation for creating views](../../..//HTTP/Views/ArangoSearch.html).
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
const view = db.arangoSearchView('potatoes');
|
||||
await view.create()
|
||||
// the arangosearch view "potatoes" now exists
|
||||
```
|
||||
|
||||
## view.setProperties
|
||||
|
||||
`async view.setProperties(properties): Object`
|
||||
|
||||
Updates the properties of the view.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **properties**: `Object`
|
||||
|
||||
For information on the _properties_ argument see
|
||||
[the HTTP API for modifying views](../../..//HTTP/Views/ArangoSearch.html).
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
const view = db.arangoSearchView('some-view');
|
||||
const result = await view.setProperties({ locale: "C" })
|
||||
assert.equal(result.locale, "C");
|
||||
```
|
||||
|
||||
## view.replaceProperties
|
||||
|
||||
`async view.replaceProperties(properties): Object`
|
||||
|
||||
Replaces the properties of the view.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **properties**: `Object`
|
||||
|
||||
For information on the _properties_ argument see
|
||||
[the HTTP API for modifying views](../../..//HTTP/Views/ArangoSearch.html).
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
const view = db.arangoSearchView('some-view');
|
||||
const result = await view.replaceProperties({ locale: "C" })
|
||||
assert.equal(result.locale, "C");
|
||||
```
|
||||
|
||||
## view.rename
|
||||
|
||||
`async view.rename(name): Object`
|
||||
|
||||
Renames the view. The _View_ instance will automatically update its
|
||||
name when the rename succeeds.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
const view = db.arangoSearchView('some-view');
|
||||
const result = await view.rename('new-view-name')
|
||||
assert.equal(result.name, 'new-view-name');
|
||||
assert.equal(view.name, result.name);
|
||||
// result contains additional information about the view
|
||||
```
|
||||
|
||||
## view.drop
|
||||
|
||||
`async view.drop(): Object`
|
||||
|
||||
Deletes the view from the database.
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const db = new Database();
|
||||
const view = db.arangoSearchView('some-view');
|
||||
await view.drop();
|
||||
// the view "some-view" no longer exists
|
||||
```
|
|
@ -0,0 +1,65 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
|
||||
# Accessing views
|
||||
|
||||
These functions implement the
|
||||
[HTTP API for accessing view](../../../..//HTTP/Views/Getting.html).
|
||||
|
||||
## ArangoDatabase.view
|
||||
|
||||
```
|
||||
ArangoDatabase.view(String name) : ArangoView
|
||||
```
|
||||
|
||||
Returns a _ArangoView_ instance for the given view name.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **name**: `String`
|
||||
|
||||
Name of the view
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoView view = db.view("myView");
|
||||
```
|
||||
|
||||
## ArangoDatabase.arangoSearch
|
||||
|
||||
```
|
||||
ArangoDatabase.arangoSearch(String name) : ArangoSearch
|
||||
```
|
||||
|
||||
Returns a _ArangoSearch_ instance for the given ArangoSearch view name.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **name**: `String`
|
||||
|
||||
Name of the view
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoSearch view = db.arangoSearch("myArangoSearchView");
|
||||
```
|
||||
|
||||
## ArangoDatabase.getViews
|
||||
|
||||
```
|
||||
ArangoDatabase.getViews() : Collection<ViewEntity>
|
||||
```
|
||||
|
||||
Fetches all views from the database and returns an list of collection descriptions.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
Collection<ViewEntity> infos = db.getViews();
|
||||
```
|
|
@ -5,6 +5,7 @@
|
|||
- [Database](Database/README.md)
|
||||
- [Database Manipulation](Database/DatabaseManipulation.md)
|
||||
- [Collection Access](Database/CollectionAccess.md)
|
||||
- [View Access](Database/ViewAccess.md)
|
||||
- [Queries](Database/Queries.md)
|
||||
- [AQL User Functions](Database/AqlUserFunctions.md)
|
||||
- [Transactions](Database/Transactions.md)
|
||||
|
@ -15,6 +16,9 @@
|
|||
- [Document Manipulation](Collection/DocumentManipulation.md)
|
||||
- [Indexes](Collection/Indexes.md)
|
||||
- [Bulk Import](Collection/BulkImport.md)
|
||||
- [View](View/README.md)
|
||||
- [View Manipulation](View/ViewManipulation.md)
|
||||
- [ArangoSearch Views](View/ArangoSearch.md)
|
||||
- [Cursor](Cursor.md)
|
||||
- [Graph](Graph/README.md)
|
||||
- [Vertex Collection](Graph/VertexCollection.md)
|
||||
|
|
|
@ -89,9 +89,10 @@ ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJodaModule())
|
|||
|
||||
## Use of jackson as an alternative serializer
|
||||
|
||||
Since version 4.5.2, the driver supports alternative serializer to de-/serialize documents, edges and query results.
|
||||
One implementation is [VelocyJack](https://github.com/arangodb/jackson-dataformat-velocypack#within-arangodb-java-driver) which is based on
|
||||
[Jackson](https://github.com/FasterXML/jackson) working with
|
||||
Since version 4.5.2, the driver supports alternative serializer to de-/serialize
|
||||
documents, edges and query results. One implementation is
|
||||
[VelocyJack](https://github.com/arangodb/jackson-dataformat-velocypack#within-arangodb-java-driver)
|
||||
which is based on [Jackson](https://github.com/FasterXML/jackson) working with
|
||||
[jackson-dataformat-velocypack](https://github.com/arangodb/jackson-dataformat-velocypack).
|
||||
|
||||
**Note**: Any registered custom [serializer/deserializer or module](#custom-serialization) will be ignored.
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
|
||||
# ArangoSearch API
|
||||
|
||||
These functions implement the
|
||||
[HTTP API for ArangoSearch views](../../../..//HTTP/Views/ArangoSearch.html).
|
||||
|
||||
## ArangoDatabase.createArangoSearch
|
||||
|
||||
```
|
||||
ArangoDatabase.createArangoSearch(String name, ArangoSearchCreateOptions options) : ViewEntity
|
||||
```
|
||||
|
||||
Creates a ArangoSearch view with the given _options_, then returns view information from the server.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **name**: `String`
|
||||
|
||||
The name of the view
|
||||
|
||||
- **options**: `ArangoSearchCreateOptions`
|
||||
|
||||
- **locale**: `String`
|
||||
|
||||
The default locale used for queries on analyzed string values (default: C).
|
||||
|
||||
- **commitIntervalMsec**: `Long`
|
||||
|
||||
Wait at least this many milliseconds between committing index data changes and making them visible to queries (default: 60000, to disable use: 0). For the case where there are a lot of inserts/updates, a lower value, until commit, will cause the index not to account for them and memory usage would continue to grow. For the case where there are a few inserts/updates, a higher value will impact performance and waste disk space for each commit call without any added benefits.
|
||||
|
||||
- **cleanupIntervalStep**: `Long`
|
||||
|
||||
Wait at least this many commits between removing unused files in data directory (default: 10, to disable use: 0). For the case where the consolidation policies merge segments often (i.e. a lot of commit+consolidate), a lower value will cause a lot of disk space to be wasted. For the case where the consolidation policies rarely merge segments (i.e. few inserts/deletes), a higher value will impact performance without any added benefits.
|
||||
|
||||
- **threshold**: `ConsolidateThreshold[]`
|
||||
|
||||
A list of consolidate thresholds
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
db.createArangoSearch("potatos", new ArangoSearchPropertiesOptions());
|
||||
// the ArangoSearch view "potatos" now exists
|
||||
```
|
||||
|
||||
## ArangoSearch.create
|
||||
|
||||
```
|
||||
ArangoSearch.create(ArangoSearchCreateOptions options) : ViewEntity
|
||||
```
|
||||
|
||||
Creates a ArangoSearch view with the given _options_, then returns view information from the server.
|
||||
|
||||
Alternative for [ArangoDatabase.createArangoSearch](#arangodatabasecreatearangosearch).
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **options**: `ArangoSearchCreateOptions`
|
||||
|
||||
- **locale**: `String`
|
||||
|
||||
The default locale used for queries on analyzed string values (default: C).
|
||||
|
||||
- **commitIntervalMsec**: `Long`
|
||||
|
||||
Wait at least this many milliseconds between committing index data changes and making them visible to queries (default: 60000, to disable use: 0). For the case where there are a lot of inserts/updates, a lower value, until commit, will cause the index not to account for them and memory usage would continue to grow. For the case where there are a few inserts/updates, a higher value will impact performance and waste disk space for each commit call without any added benefits.
|
||||
|
||||
- **cleanupIntervalStep**: `Long`
|
||||
|
||||
Wait at least this many commits between removing unused files in data directory (default: 10, to disable use: 0). For the case where the consolidation policies merge segments often (i.e. a lot of commit+consolidate), a lower value will cause a lot of disk space to be wasted. For the case where the consolidation policies rarely merge segments (i.e. few inserts/deletes), a higher value will impact performance without any added benefits.
|
||||
|
||||
- **threshold**: `ConsolidateThreshold[]`
|
||||
|
||||
A list of consolidate thresholds
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoSearch view = db.arangoSearch("potatos");
|
||||
|
||||
view.create(new ArangoSearchPropertiesOptions());
|
||||
// the ArangoSearch view "potatos" now exists
|
||||
```
|
||||
|
||||
## ArangoSearch.getProperties
|
||||
|
||||
```
|
||||
ArangoSearch.getProperties() : ArangoSearchPropertiesEntity
|
||||
```
|
||||
|
||||
Reads the properties of the specified view.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoSearch view = db.arangoSearch("potatos");
|
||||
|
||||
ArangoSearchPropertiesEntity properties = view.getProperties();
|
||||
```
|
||||
|
||||
## ArangoSearch.updateProperties
|
||||
|
||||
```
|
||||
ArangoSearch.updateProperties(ArangoSearchPropertiesOptions options) : ArangoSearchPropertiesEntity
|
||||
```
|
||||
|
||||
Partially changes properties of the view.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **options**: `ArangoSearchPropertiesOptions`
|
||||
|
||||
- **locale**: `String`
|
||||
|
||||
The default locale used for queries on analyzed string values (default: C).
|
||||
|
||||
- **commitIntervalMsec**: `Long`
|
||||
|
||||
Wait at least this many milliseconds between committing index data changes and making them visible to queries (default: 60000, to disable use: 0). For the case where there are a lot of inserts/updates, a lower value, until commit, will cause the index not to account for them and memory usage would continue to grow. For the case where there are a few inserts/updates, a higher value will impact performance and waste disk space for each commit call without any added benefits.
|
||||
|
||||
- **cleanupIntervalStep**: `Long`
|
||||
|
||||
Wait at least this many commits between removing unused files in data directory (default: 10, to disable use: 0). For the case where the consolidation policies merge segments often (i.e. a lot of commit+consolidate), a lower value will cause a lot of disk space to be wasted. For the case where the consolidation policies rarely merge segments (i.e. few inserts/deletes), a higher value will impact performance without any added benefits.
|
||||
|
||||
- **threshold**: `ConsolidateThreshold[]`
|
||||
|
||||
A list of consolidate thresholds
|
||||
|
||||
- **link**: `CollectionLink[]`
|
||||
|
||||
A list of linked collections
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoSearch view = db.arangoSearch("some-view");
|
||||
|
||||
view.updateProperties(new ArangoSearchPropertiesOptions().link(CollectionLink.on("myCollection").fields(FieldLink.on("value").analyzers("identity"))));
|
||||
```
|
||||
|
||||
## ArangoSearch.replaceProperties
|
||||
|
||||
```
|
||||
ArangoSearch.replaceProperties(ArangoSearchPropertiesOptions options) : ArangoSearchPropertiesEntity
|
||||
```
|
||||
|
||||
Changes properties of the view.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **options**: `ArangoSearchPropertiesOptions`
|
||||
|
||||
- **locale**: `String`
|
||||
|
||||
The default locale used for queries on analyzed string values (default: C).
|
||||
|
||||
- **commitIntervalMsec**: `Long`
|
||||
|
||||
Wait at least this many milliseconds between committing index data changes and making them visible to queries (default: 60000, to disable use: 0). For the case where there are a lot of inserts/updates, a lower value, until commit, will cause the index not to account for them and memory usage would continue to grow. For the case where there are a few inserts/updates, a higher value will impact performance and waste disk space for each commit call without any added benefits.
|
||||
|
||||
- **cleanupIntervalStep**: `Long`
|
||||
|
||||
Wait at least this many commits between removing unused files in data directory (default: 10, to disable use: 0). For the case where the consolidation policies merge segments often (i.e. a lot of commit+consolidate), a lower value will cause a lot of disk space to be wasted. For the case where the consolidation policies rarely merge segments (i.e. few inserts/deletes), a higher value will impact performance without any added benefits.
|
||||
|
||||
- **threshold**: `ConsolidateThreshold[]`
|
||||
|
||||
A list of consolidate thresholds
|
||||
|
||||
- **link**: `CollectionLink[]`
|
||||
|
||||
A list of linked collections
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoSearch view = db.arangoSearch("some-view");
|
||||
|
||||
view.replaceProperties(new ArangoSearchPropertiesOptions().link(CollectionLink.on("myCollection").fields(FieldLink.on("value").analyzers("identity"))));
|
||||
```
|
|
@ -0,0 +1,47 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
|
||||
# View API
|
||||
|
||||
These functions implement the
|
||||
[HTTP API for views](../../../..//HTTP/Views/index.html).
|
||||
|
||||
## Getting information about the view
|
||||
|
||||
See
|
||||
[the HTTP API documentation](../../../..//HTTP/Views/Getting.html)
|
||||
for details.
|
||||
|
||||
## ArangoView.exists
|
||||
|
||||
```
|
||||
ArangoView.exists() : boolean
|
||||
```
|
||||
|
||||
Checks whether the view exists
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoView view = db.view("potatos");
|
||||
|
||||
boolean exists = view.exists();
|
||||
```
|
||||
|
||||
## ArangoView.getInfo
|
||||
|
||||
```
|
||||
ArangoView.getInfo() : ViewEntity
|
||||
```
|
||||
|
||||
Returns information about the view.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoView view = db.view("potatos");
|
||||
|
||||
ViewEntity info = view.getInfo();
|
||||
```
|
|
@ -0,0 +1,77 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/arangodb-java-driver.git / docs/Drivers/ -->
|
||||
# Manipulating the view
|
||||
|
||||
These functions implement
|
||||
[the HTTP API for modifying views](../../../..//HTTP/Views/Modifying.html).
|
||||
|
||||
## ArangoDatabase.createView
|
||||
|
||||
```
|
||||
ArangoDatabase.createView(String name, ViewType type) : ViewEntity
|
||||
```
|
||||
|
||||
Creates a view of the given _type_, then returns view information from the server.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **name**: `String`
|
||||
|
||||
The name of the view
|
||||
|
||||
- **type**: `ViewType`
|
||||
|
||||
The type of the view
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
db.createView("myView", ViewType.ARANGO_SEARCH);
|
||||
// the view "potatos" now exists
|
||||
```
|
||||
|
||||
## ArangoView.rename
|
||||
|
||||
```
|
||||
ArangoView.rename(String newName) : ViewEntity
|
||||
```
|
||||
|
||||
Renames the view.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **newName**: `String`
|
||||
|
||||
The new name
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoView view = db.view("some-view");
|
||||
|
||||
ViewEntity result = view.rename("new-view-name")
|
||||
assertThat(result.getName(), is("new-view-name");
|
||||
// result contains additional information about the view
|
||||
```
|
||||
|
||||
## ArangoView.drop
|
||||
|
||||
```
|
||||
ArangoView.drop() : void
|
||||
```
|
||||
|
||||
Deletes the view from the database.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
ArangoDB arango = new ArangoDB.Builder().build();
|
||||
ArangoDatabase db = arango.db("myDB");
|
||||
ArangoView view = db.view("some-view");
|
||||
|
||||
view.drop();
|
||||
// the view "some-view" no longer exists
|
||||
```
|
|
@ -12,7 +12,7 @@ The official ArangoDB PHP Driver.
|
|||
|
||||
* More example code, containing some code to create, delete and rename collections, is provided in the [examples](https://github.com/arangodb/arangodb-php/tree/devel/examples) subdirectory that is provided with the library.
|
||||
|
||||
* PHPDoc documentation for the complete library is in the library's docs subdirectory. Point your browser at this directory to get a click-through version of the documentation after cloning the repository.
|
||||
* [PHPDoc documentation](http://arangodb.github.io/arangodb-php/) for the complete library
|
||||
|
||||
* [Follow us on Twitter](https://twitter.com/arangodbphp)
|
||||
[@arangodbphp](https://twitter.com/arangodbphp) to receive updates on the PHP driver
|
||||
|
|
|
@ -9,28 +9,32 @@
|
|||
* [Java Driver](Java/README.md)
|
||||
* [Getting Started](Java/GettingStarted/README.md)
|
||||
* [Reference](Java/Reference/README.md)
|
||||
* [Driver Setup](Java/Reference/Setup.md)
|
||||
* [Database](Java/Reference/Database/README.md)
|
||||
* [Database Manipulation](Java/Reference/Database/DatabaseManipulation.md)
|
||||
* [Collection Access](Java/Reference/Database/CollectionAccess.md)
|
||||
* [Queries](Java/Reference/Database/Queries.md)
|
||||
* [AQL User Functions](Java/Reference/Database/AqlUserFunctions.md)
|
||||
* [Transactions](Java/Reference/Database/Transactions.md)
|
||||
* [Graph Access](Java/Reference/Database/GraphAccess.md)
|
||||
* [HTTP Routes](Java/Reference/Database/HttpRoutes.md)
|
||||
* [Collection](Java/Reference/Collection/README.md)
|
||||
* [Collection Manipulation](Java/Reference/Collection/CollectionManipulation.md)
|
||||
* [Document Manipulation](Java/Reference/Collection/DocumentManipulation.md)
|
||||
* [Indexes](Java/Reference/Collection/Indexes.md)
|
||||
* [Bulk Import](Java/Reference/Collection/BulkImport.md)
|
||||
* [Cursor](Java/Reference/Cursor.md)
|
||||
* [Graph](Java/Reference/Graph/README.md)
|
||||
* [Vertex Collection](Java/Reference/Graph/VertexCollection.md)
|
||||
* [Edge Collection](Java/Reference/Graph/EdgeCollection.md)
|
||||
* [Vertices Manipulation](Java/Reference/Graph/Vertices.md)
|
||||
* [Edges Manipulation](Java/Reference/Graph/Edges.md)
|
||||
* [Route](Java/Reference/Route.md)
|
||||
* [Serialization](Java/Reference/Serialization.md)
|
||||
* [Driver Setup](Java/Reference/Setup.md)
|
||||
* [Database](Java/Reference/Database/README.md)
|
||||
* [Database Manipulation](Java/Reference/Database/DatabaseManipulation.md)
|
||||
* [Collection Access](Java/Reference/Database/CollectionAccess.md)
|
||||
* [View Access](Java/Reference/Database/ViewAccess.md)
|
||||
* [Queries](Java/Reference/Database/Queries.md)
|
||||
* [AQL User Functions](Java/Reference/Database/AqlUserFunctions.md)
|
||||
* [Transactions](Java/Reference/Database/Transactions.md)
|
||||
* [Graph Access](Java/Reference/Database/GraphAccess.md)
|
||||
* [HTTP Routes](Java/Reference/Database/HttpRoutes.md)
|
||||
* [Collection](Java/Reference/Collection/README.md)
|
||||
* [Collection Manipulation](Java/Reference/Collection/CollectionManipulation.md)
|
||||
* [Document Manipulation](Java/Reference/Collection/DocumentManipulation.md)
|
||||
* [Indexes](Java/Reference/Collection/Indexes.md)
|
||||
* [Bulk Import](Java/Reference/Collection/BulkImport.md)
|
||||
* [View](Java/Reference/View/README.md)
|
||||
* [View Manipulation](Java/Reference/View/ViewManipulation.md)
|
||||
* [ArangoSearch Views](Java/Reference/View/ArangoSearch.md)
|
||||
* [Cursor](Java/Reference/Cursor.md)
|
||||
* [Graph](Java/Reference/Graph/README.md)
|
||||
* [Vertex Collection](Java/Reference/Graph/VertexCollection.md)
|
||||
* [Edge Collection](Java/Reference/Graph/EdgeCollection.md)
|
||||
* [Vertices Manipulation](Java/Reference/Graph/Vertices.md)
|
||||
* [Edges Manipulation](Java/Reference/Graph/Edges.md)
|
||||
* [Route](Java/Reference/Route.md)
|
||||
* [Serialization](Java/Reference/Serialization.md)
|
||||
# https://@github.com/arangodb/arangodbjs.git;arangodbjs;docs/Drivers;;/
|
||||
* [ArangoJS - JavaScript Driver](JS/README.md)
|
||||
* [Getting Started](JS/GettingStarted/README.md)
|
||||
|
@ -38,6 +42,7 @@
|
|||
* [Database](JS/Reference/Database/README.md)
|
||||
* [Database Manipulation](JS/Reference/Database/DatabaseManipulation.md)
|
||||
* [Collection Access](JS/Reference/Database/CollectionAccess.md)
|
||||
* [View Access](JS/Reference/Database/ViewAccess.md)
|
||||
* [Queries](JS/Reference/Database/Queries.md)
|
||||
* [AQL User Functions](JS/Reference/Database/AqlUserFunctions.md)
|
||||
* [Transactions](JS/Reference/Database/Transactions.md)
|
||||
|
@ -52,6 +57,7 @@
|
|||
* [Indexes](JS/Reference/Collection/Indexes.md)
|
||||
* [Simple Queries](JS/Reference/Collection/SimpleQueries.md)
|
||||
* [Bulk Import](JS/Reference/Collection/BulkImport.md)
|
||||
* [View Manipulation](JS/Reference/ViewManipulation.md)
|
||||
* [Cursor](JS/Reference/Cursor.md)
|
||||
* [Graph](JS/Reference/Graph/README.md)
|
||||
* [Vertices](JS/Reference/Graph/Vertices.md)
|
||||
|
@ -75,6 +81,31 @@
|
|||
* [Spring Data ArangoDB](SpringData/README.md)
|
||||
* [Getting Started](SpringData/GettingStarted/README.md)
|
||||
* [Reference](SpringData/Reference/README.md)
|
||||
* [Template](SpringData/Reference/Template/README.md)
|
||||
* [Queries](SpringData/Reference/Template/Queries.md)
|
||||
* [Document Manipulation](SpringData/Reference/Template/DocumentManipulation.md)
|
||||
* [Multiple Document Manipulation](SpringData/Reference/Template/MultiDocumentManipulation.md)
|
||||
* [Collection Manipulation](SpringData/Reference/Template/CollectionManipulation.md)
|
||||
* [Repositories](SpringData/Reference/Repositories/README.md)
|
||||
* [Queries](SpringData/Reference/Repositories/Queries/README.md)
|
||||
* [Derived queries](SpringData/Reference/Repositories/Queries/DerivedQueries.md)
|
||||
* [Query methods](SpringData/Reference/Repositories/Queries/QueryMethods.md)
|
||||
* [Named queries](SpringData/Reference/Repositories/Queries/NamedQueries.md)
|
||||
* [Document Manipulation](SpringData/Reference/Repositories/DocumentManipulation.md)
|
||||
* [Multiple Document Manipulation](SpringData/Reference/Repositories/MultiDocumentManipulation.md)
|
||||
* [Query by example](SpringData/Reference/Repositories/QueryByExample.md)
|
||||
* [Mapping](SpringData/Reference/Mapping/README.md)
|
||||
* [Document](SpringData/Reference/Mapping/Document.md)
|
||||
* [Edge](SpringData/Reference/Mapping/Edge.md)
|
||||
* [Reference](SpringData/Reference/Mapping/Reference.md)
|
||||
* [Relations](SpringData/Reference/Mapping/Relations.md)
|
||||
* [Indexes](SpringData/Reference/Mapping/Indexes.md)
|
||||
* [Converter](SpringData/Reference/Mapping/Converter.md)
|
||||
* [Events](SpringData/Reference/Mapping/Events.md)
|
||||
* [Migration](SpringData/Migration/README.md)
|
||||
* [Migrating 1.x to 3.0](SpringData/Migration/Migrating-1.x-3.0.md)
|
||||
* [Migrating 2.x to 3.0](SpringData/Migration/Migrating-2.x-3.0.md)
|
||||
|
||||
# https://@github.com/arangodb/arangodb-spark-connector.git;arangodb-spark-connector;docs/Drivers;;/
|
||||
* [ArangoDB Spark Connector](SparkConnector/README.md)
|
||||
* [Getting Started](SparkConnector/GettingStarted/README.md)
|
||||
|
|
|
@ -1,115 +1,118 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Spring Data ArangoDB - Getting Started
|
||||
|
||||
## Supported versions
|
||||
|
||||
| Spring Data ArangoDB | Spring Data | ArangoDB |
|
||||
|----------------------|-------------|----------------|
|
||||
| 1.0.0 | 1.13.x | 3.0*, 3.1, 3.2 |
|
||||
| 2.0.0 | 2.0.x | 3.0*, 3.1, 3.2 |
|
||||
|
||||
Spring Data ArangoDB requires ArangoDB 3.0 or higher - which you can download [here](https://www.arangodb.com/download/) - and Java 8 or higher.
|
||||
|
||||
**Note**: ArangoDB 3.0 does not support the default transport protocol [VelocyStream](https://github.com/arangodb/velocystream).
|
||||
A manual switch to HTTP is required. See chapter [configuration](#configuration). Also ArangoDB 3.0 does not support geospatial queries.
|
||||
|
||||
## Maven
|
||||
|
||||
To use Spring Data ArangoDB in your project, your build automation tool needs to be configured to include and use the Spring Data ArangoDB dependency. Example with Maven:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.arangodb</groupId>
|
||||
<artifactId>arangodb-spring-data</artifactId>
|
||||
<version>{version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
There is a [demonstration app](https://github.com/arangodb/spring-data-demo), which contains common use cases and examples of how to use Spring Data ArangoDB's functionality.
|
||||
|
||||
## Configuration
|
||||
|
||||
You can use Java to configure your Spring Data environment as show below. Setting up the underlying driver (`ArangoDB.Builder`) with default configuration automatically loads a properties file `arangodb.properties`, if it exists in the classpath.
|
||||
|
||||
```java
|
||||
@Configuration
|
||||
@EnableArangoRepositories(basePackages = { "com.company.mypackage" })
|
||||
public class MyConfiguration extends AbstractArangoConfiguration {
|
||||
|
||||
@Override
|
||||
public ArangoDB.Builder arango() {
|
||||
return new ArangoDB.Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String database() {
|
||||
// Name of the database to be used
|
||||
return "example-database";
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The driver is configured with some default values:
|
||||
|
||||
property-key | description | default value
|
||||
-------------|-------------|--------------
|
||||
arangodb.host | ArangoDB host | 127.0.0.1
|
||||
arangodb.port | ArangoDB port | 8529
|
||||
arangodb.timeout | socket connect timeout(millisecond) | 0
|
||||
arangodb.user | Basic Authentication User |
|
||||
arangodb.password | Basic Authentication Password |
|
||||
arangodb.useSsl | use SSL connection | false
|
||||
|
||||
To customize the configuration, the parameters can be changed in the Java code.
|
||||
|
||||
```java
|
||||
@Override
|
||||
public ArangoDB.Builder arango() {
|
||||
ArangoDB.Builder arango = new ArangoDB.Builder()
|
||||
.host("127.0.0.1")
|
||||
.port(8429)
|
||||
.user("root");
|
||||
return arango;
|
||||
}
|
||||
```
|
||||
|
||||
In addition you can use the *arangodb.properties* or a custom properties file to supply credentials to the driver.
|
||||
|
||||
*Properties file*
|
||||
```
|
||||
arangodb.host=127.0.0.1
|
||||
arangodb.port=8529
|
||||
# arangodb.hosts=127.0.0.1:8529 could be used instead
|
||||
arangodb.user=root
|
||||
arangodb.password=
|
||||
```
|
||||
|
||||
*Custom properties file*
|
||||
```java
|
||||
@Override
|
||||
public ArangoDB.Builder arango() {
|
||||
InputStream in = MyClass.class.getResourceAsStream("my.properties");
|
||||
ArangoDB.Builder arango = new ArangoDB.Builder()
|
||||
.loadProperties(in);
|
||||
return arango;
|
||||
}
|
||||
```
|
||||
|
||||
**Note**: When using ArangoDB 3.0 it is required to set the transport protocol to HTTP and fetch the dependency `org.apache.httpcomponents:httpclient`.
|
||||
|
||||
```java
|
||||
@Override
|
||||
public ArangoDB.Builder arango() {
|
||||
ArangoDB.Builder arango = new ArangoDB.Builder()
|
||||
.useProtocol(Protocol.HTTP_JSON);
|
||||
return arango;
|
||||
}
|
||||
```
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.1</version>
|
||||
</dependency>
|
||||
```
|
||||
# Spring Data ArangoDB - Getting Started
|
||||
|
||||
## Supported versions
|
||||
|
||||
| Spring Data ArangoDB | Spring Data | ArangoDB |
|
||||
| -------------------- | ----------- | ----------- |
|
||||
| 1.x.x | 1.13.x | 3.0\*, 3.1+ |
|
||||
| 2.x.x | 2.0.x | 3.0\*, 3.1+ |
|
||||
|
||||
Spring Data ArangoDB requires ArangoDB 3.0 or higher - which you can download [here](https://www.arangodb.com/download/) - and Java 8 or higher.
|
||||
|
||||
**Note**: ArangoDB 3.0 does not support the default transport protocol
|
||||
[VelocyStream](https://github.com/arangodb/velocystream). A manual switch to
|
||||
HTTP is required. See chapter [configuration](#configuration). Also ArangoDB 3.0
|
||||
does not support geospatial queries.
|
||||
|
||||
## Maven
|
||||
|
||||
To use Spring Data ArangoDB in your project, your build automation tool needs to be configured to include and use the Spring Data ArangoDB dependency. Example with Maven:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.arangodb</groupId>
|
||||
<artifactId>arangodb-spring-data</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
There is a [demonstration app](https://github.com/arangodb/spring-data-demo), which contains common use cases and examples of how to use Spring Data ArangoDB's functionality.
|
||||
|
||||
## Configuration
|
||||
|
||||
You can use Java to configure your Spring Data environment as show below. Setting up the underlying driver (`ArangoDB.Builder`) with default configuration automatically loads a properties file `arangodb.properties`, if it exists in the classpath.
|
||||
|
||||
```java
|
||||
@Configuration
|
||||
@EnableArangoRepositories(basePackages = { "com.company.mypackage" })
|
||||
public class MyConfiguration extends AbstractArangoConfiguration {
|
||||
|
||||
@Override
|
||||
public ArangoDB.Builder arango() {
|
||||
return new ArangoDB.Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String database() {
|
||||
// Name of the database to be used
|
||||
return "example-database";
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The driver is configured with some default values:
|
||||
|
||||
| property-key | description | default value |
|
||||
| ----------------- | ----------------------------------- | ------------- |
|
||||
| arangodb.host | ArangoDB host | 127.0.0.1 |
|
||||
| arangodb.port | ArangoDB port | 8529 |
|
||||
| arangodb.timeout | socket connect timeout(millisecond) | 0 |
|
||||
| arangodb.user | Basic Authentication User |
|
||||
| arangodb.password | Basic Authentication Password |
|
||||
| arangodb.useSsl | use SSL connection | false |
|
||||
|
||||
To customize the configuration, the parameters can be changed in the Java code.
|
||||
|
||||
```java
|
||||
@Override
|
||||
public ArangoDB.Builder arango() {
|
||||
ArangoDB.Builder arango = new ArangoDB.Builder()
|
||||
.host("127.0.0.1")
|
||||
.port(8529)
|
||||
.user("root");
|
||||
return arango;
|
||||
}
|
||||
```
|
||||
|
||||
In addition you can use the _arangodb.properties_ or a custom properties file to supply credentials to the driver.
|
||||
|
||||
_Properties file_
|
||||
|
||||
```
|
||||
arangodb.hosts=127.0.0.1:8529
|
||||
arangodb.user=root
|
||||
arangodb.password=
|
||||
```
|
||||
|
||||
_Custom properties file_
|
||||
|
||||
```java
|
||||
@Override
|
||||
public ArangoDB.Builder arango() {
|
||||
InputStream in = MyClass.class.getResourceAsStream("my.properties");
|
||||
ArangoDB.Builder arango = new ArangoDB.Builder()
|
||||
.loadProperties(in);
|
||||
return arango;
|
||||
}
|
||||
```
|
||||
|
||||
**Note**: When using ArangoDB 3.0 it is required to set the transport protocol to HTTP and fetch the dependency `org.apache.httpcomponents:httpclient`.
|
||||
|
||||
```java
|
||||
@Override
|
||||
public ArangoDB.Builder arango() {
|
||||
ArangoDB.Builder arango = new ArangoDB.Builder()
|
||||
.useProtocol(Protocol.HTTP_JSON);
|
||||
return arango;
|
||||
}
|
||||
```
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.1</version>
|
||||
</dependency>
|
||||
```
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Migrating Spring Data ArangoDB 2.x to 3.0
|
||||
|
||||
see [Migrating 2.x to 3.0](Migrating-2.x-3.0.md)
|
|
@ -0,0 +1,42 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Migrating Spring Data ArangoDB 2.x to 3.0
|
||||
|
||||
## Annotations @Key
|
||||
|
||||
The annotation `@Key` is removed. Use `@Id` instead.
|
||||
|
||||
## Annotations @Id
|
||||
|
||||
The annotation `@Id` is now saved in the database as field `_key` instead of `_id`. All operations in `ArangoOperations` and `ArangoRepository` still work with `@Id` and also now supports non-String fields.
|
||||
|
||||
If you - for some reason - need the value of `_id` within your application, you can use the annotation `@ArangoId` on a `String` field instead of `@Id`.
|
||||
|
||||
**Note**: The field annotated with `@ArangoId` will not be persisted in the database. It only exists for reading purposes.
|
||||
|
||||
## ArangoRepository
|
||||
|
||||
`ArangoRepository` now requires a second generic type. This type `ID` represents the type of your domain object field annotated with `@Id`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
public class Customer {
|
||||
@Id private String id;
|
||||
}
|
||||
|
||||
public interface CustomerRepository extends ArangoRepository<Customer, String> {
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Annotation @Param
|
||||
|
||||
The annotation `com.arangodb.springframework.annotation.Param` is removed. Use `org.springframework.data.repository.query.Param` instead.
|
||||
|
||||
## DBEntity
|
||||
|
||||
`DBEntity` is removed. Use `VPackSlice` in your converter instead.
|
||||
|
||||
## DBCollectionEntity
|
||||
|
||||
`DBCollectionEntity` is removed. Use `VPackSlice` in your converter instead.
|
|
@ -0,0 +1,5 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Spring Data ArangoDB - Migration
|
||||
|
||||
- [Migrating 1.x to 3.0](Migrating-1.x-3.0.md)
|
||||
- [Migrating 2.x to 3.0](Migrating-2.x-3.0.md)
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
- [Getting Started](GettingStarted/README.md)
|
||||
- [Reference](Reference/README.md)
|
||||
- [Migration](Migration/README.md)
|
||||
|
||||
## Learn more
|
||||
|
||||
|
@ -10,5 +11,4 @@
|
|||
- [Demo](https://github.com/arangodb/spring-data-demo)
|
||||
- [JavaDoc 1.0.0](http://arangodb.github.io/spring-data/javadoc-1_0/index.html)
|
||||
- [JavaDoc 2.0.0](http://arangodb.github.io/spring-data/javadoc-2_0/index.html)
|
||||
- [JavaDoc Java driver](http://arangodb.github.io/arangodb-java-driver/javadoc-4_3/index.html)
|
||||
- [Changelog](https://github.com/arangodb/spring-data/blob/master/ChangeLog.md#changelog)
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Converter
|
||||
|
||||
## Registering a Spring Converter
|
||||
|
||||
The `AbstractArangoConfiguration` provides a convenient way to register Spring `Converter` by overriding the method `customConverters()`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Configuration
|
||||
public class MyConfiguration extends AbstractArangoConfiguration {
|
||||
|
||||
@Override
|
||||
protected Collection<Converter<?, ?>> customConverters() {
|
||||
Collection<Converter<?, ?>> converters = new ArrayList<>();
|
||||
converters.add(new MyConverter());
|
||||
return converters;
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Implementing a Spring Converter
|
||||
|
||||
A `Converter` is used for reading if the source type is of type `VPackSlice` or `DBDocumentEntity`.
|
||||
|
||||
A `Converter` is used for writing if the target type is of type `VPackSlice`, `DBDocumentEntity`, `BigInteger`, `BigDecimal`, `java.sql.Date`, `java.sql.Timestamp`, `Instant`, `LocalDate`, `LocalDateTime`, `OffsetDateTime`, `ZonedDateTime`, `Boolean`, `Short`, `Integer`, `Byte`, `Float`, `Double`, `Character`, `String`, `Date`, `Class`, `Enum`, `boolean[]`, `long[]`, `short[]`, `int[]`, `byte[]`, `float[]`, `double[]` or `char[]`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
public class MyConverter implements Converter<MyObject, VPackSlice> {
|
||||
|
||||
@Override
|
||||
public VPackSlice convert(final MyObject source) {
|
||||
VPackBuilder builder = new VPackBuilder();
|
||||
// map fields of MyObject to builder
|
||||
return builder.slice();
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
For performance reasons `VPackSlice` should always be used within a converter. If your object is too complexe, you can also use `DBDocumentEntity` to simplify the mapping.
|
|
@ -0,0 +1,79 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Document
|
||||
|
||||
## Annotation @Document
|
||||
|
||||
The annotations `@Document` applied to a class marks this class as a candidate for mapping to the database. The most relevant parameter is `value` to specify the collection name in the database. The annotation `@Document` specifies the collection type to `DOCUMENT`.
|
||||
|
||||
```java
|
||||
@Document(value="persons")
|
||||
public class Person {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Spring Expression support
|
||||
|
||||
Spring Data ArangoDB supports the use of SpEL expressions within `@Document#value`. This feature lets you define a dynamic collection name which can be used to implement multi tenancy applications.
|
||||
|
||||
```Java
|
||||
@Component
|
||||
public class TenantProvider {
|
||||
|
||||
public String getId() {
|
||||
// threadlocal lookup
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
```java
|
||||
@Document("#{tenantProvider.getId()}_persons")
|
||||
public class Person {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Annotation @From and @To
|
||||
|
||||
With the annotations `@From` and `@To` applied on a collection or array field in a class annotated with `@Document` the nested edge objects are fetched from the database. Each of the nested edge objects has to be stored as separate edge document in the edge collection described in the `@Edge` annotation of the nested object class with the _\_id_ of the parent document as field _\_from_ or _\_to_.
|
||||
|
||||
```java
|
||||
@Document("persons")
|
||||
public class Person {
|
||||
@From
|
||||
private List<Relation> relations;
|
||||
}
|
||||
|
||||
@Edge(name="relations")
|
||||
public class Relation {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
The database representation of `Person` in collection _persons_ looks as follow:
|
||||
|
||||
```
|
||||
{
|
||||
"_key" : "123",
|
||||
"_id" : "persons/123"
|
||||
}
|
||||
```
|
||||
|
||||
and the representation of `Relation` in collection _relations_:
|
||||
|
||||
```
|
||||
{
|
||||
"_key" : "456",
|
||||
"_id" : "relations/456",
|
||||
"_from" : "persons/123"
|
||||
"_to" : ".../..."
|
||||
}
|
||||
{
|
||||
"_key" : "789",
|
||||
"_id" : "relations/456",
|
||||
"_from" : "persons/123"
|
||||
"_to" : ".../..."
|
||||
}
|
||||
...
|
||||
```
|
|
@ -0,0 +1,81 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Edge
|
||||
|
||||
## Annotation @Edge
|
||||
|
||||
The annotations `@Edge` applied to a class marks this class as a candidate for mapping to the database. The most relevant parameter is `value` to specify the collection name in the database. The annotation `@Edge` specifies the collection type to `EDGE`.
|
||||
|
||||
```java
|
||||
@Edge("relations")
|
||||
public class Relation {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Spring Expression support
|
||||
|
||||
Spring Data ArangoDB supports the use of SpEL expressions within `@Edge#value`. This feature lets you define a dynamic collection name which can be used to implement multi tenancy applications.
|
||||
|
||||
```Java
|
||||
@Component
|
||||
public class TenantProvider {
|
||||
|
||||
public String getId() {
|
||||
// threadlocal lookup
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
```java
|
||||
@Edge("#{tenantProvider.getId()}_relations")
|
||||
public class Relation {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Annotation @From and @To
|
||||
|
||||
With the annotations `@From` and `@To` applied on a field in a class annotated with `@Edge` the nested object is fetched from the database. The nested object has to be stored as a separate document in the collection described in the `@Document` annotation of the nested object class. The _\_id_ field of this nested object is stored in the fields `_from` or `_to` within the edge document.
|
||||
|
||||
```java
|
||||
@Edge("relations")
|
||||
public class Relation {
|
||||
@From
|
||||
private Person c1;
|
||||
@To
|
||||
private Person c2;
|
||||
}
|
||||
|
||||
@Document(value="persons")
|
||||
public class Person {
|
||||
@Id
|
||||
private String id;
|
||||
}
|
||||
```
|
||||
|
||||
The database representation of `Relation` in collection _relations_ looks as follow:
|
||||
|
||||
```
|
||||
{
|
||||
"_key" : "123",
|
||||
"_id" : "relations/123",
|
||||
"_from" : "persons/456",
|
||||
"_to" : "persons/789"
|
||||
}
|
||||
```
|
||||
|
||||
and the representation of `Person` in collection _persons_:
|
||||
|
||||
```
|
||||
{
|
||||
"_key" : "456",
|
||||
"_id" : "persons/456",
|
||||
}
|
||||
{
|
||||
"_key" : "789",
|
||||
"_id" : "persons/789",
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** If you want to save an instance of `Relation`, both `Person` objects (from & to) already have to be persisted and the class `Person` needs a field with the annotation `@Id` so it can hold the persisted `_id` from the database.
|
|
@ -0,0 +1,36 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Events
|
||||
|
||||
Srping Data ArangoDB includes several `ApplicationEvent` events that your application can respond to by registering subclasses of `AbstractArangoEventListener` in the ApplicationContext.
|
||||
|
||||
The following callback methods are present in `AbstractArangoEventListener`:
|
||||
|
||||
- `onAfterLoad`: Called in `ArangoTemplate#find` and `ArangoTemplate#query` after the object is loaded from the database.
|
||||
- `onBeforeSave`: Called in `ArangoTemplate#insert`/`#update`/`#replace` before the object is converted and send to the database.
|
||||
- `onAfterSave`: Called in `ArangoTemplate#insert`/`#update`/`#replace` after the object is send to the database.
|
||||
- `onBeforeDelete`: Called in `ArangoTemplate#delete` before the object is converted and send to the database.
|
||||
- `onAfterDelete`: Called in `ArangoTemplate#delete` after the object is deleted from the database.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
package my.mapping.events;
|
||||
|
||||
public class BeforePersonSavedListener extends AbstractArangoEventListener<Person> {
|
||||
|
||||
@Override
|
||||
public void onBeforeSave(BeforeSaveEvent<Person> event) {
|
||||
// do some logging or data manipulation
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
To register the listener add `@ComponentScan` with the package of your listener to your configuration class.
|
||||
|
||||
```Java
|
||||
@Configuration
|
||||
@ComponentScan("my.mapping.events")
|
||||
public class MyConfiguration extends AbstractArangoConfiguration {
|
||||
...
|
||||
```
|
|
@ -0,0 +1,105 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Indexes
|
||||
|
||||
## Annotation @\<IndexType\>Indexed
|
||||
|
||||
With the `@<IndexType>Indexed` annotations user defined indexes can be created at a collection level by annotating single fields of a class.
|
||||
|
||||
Possible `@<IndexType>Indexed` annotations are:
|
||||
|
||||
- `@HashIndexed`
|
||||
- `@SkiplistIndexed`
|
||||
- `@PersistentIndexed`
|
||||
- `@GeoIndexed`
|
||||
- `@FulltextIndexed`
|
||||
|
||||
The following example creates a hash index on the field `name` and a separate hash index on the field `age`:
|
||||
|
||||
```java
|
||||
public class Person {
|
||||
@HashIndexed
|
||||
private String name;
|
||||
|
||||
@HashIndexed
|
||||
private int age;
|
||||
}
|
||||
```
|
||||
|
||||
With the `@<IndexType>Indexed` annotations different indexes can be created on the same field.
|
||||
|
||||
The following example creates a hash index and also a skiplist index on the field `name`:
|
||||
|
||||
```java
|
||||
public class Person {
|
||||
@HashIndexed
|
||||
@SkiplistIndexed
|
||||
private String name;
|
||||
}
|
||||
```
|
||||
|
||||
## Annotation @\<IndexType\>Index
|
||||
|
||||
If the index should include multiple fields the `@<IndexType>Index` annotations can be used on the type instead.
|
||||
|
||||
Possible `@<IndexType>Index` annotations are:
|
||||
|
||||
- `@HashIndex`
|
||||
- `@SkiplistIndex`
|
||||
- `@PersistentIndex`
|
||||
- `@GeoIndex`
|
||||
- `@FulltextIndex`
|
||||
|
||||
The following example creates a single hash index on the fields `name` and `age`, note that if a field is renamed in the database with @Field, the new field name must be used in the index declaration:
|
||||
|
||||
```java
|
||||
@HashIndex(fields = {"fullname", "age"})
|
||||
public class Person {
|
||||
@Field("fullname")
|
||||
private String name;
|
||||
|
||||
private int age;
|
||||
}
|
||||
```
|
||||
|
||||
The `@<IndexType>Index` annotations can also be used to create an index on a nested field.
|
||||
|
||||
The following example creates a single hash index on the fields `name` and `address.country`:
|
||||
|
||||
```java
|
||||
@HashIndex(fields = {"name", "address.country"})
|
||||
public class Person {
|
||||
private String name;
|
||||
|
||||
private Address address;
|
||||
}
|
||||
```
|
||||
|
||||
The `@<IndexType>Index` annotations and the `@<IndexType>Indexed` annotations can be used at the same time in one class.
|
||||
|
||||
The following example creates a hash index on the fields `name` and `age` and a separate hash index on the field `age`:
|
||||
|
||||
```java
|
||||
@HashIndex(fields = {"name", "age"})
|
||||
public class Person {
|
||||
private String name;
|
||||
|
||||
@HashIndexed
|
||||
private int age;
|
||||
}
|
||||
```
|
||||
|
||||
The `@<IndexType>Index` annotations can be used multiple times to create more than one index in this way.
|
||||
|
||||
The following example creates a hash index on the fields `name` and `age` and a separate hash index on the fields `name` and `gender`:
|
||||
|
||||
```java
|
||||
@HashIndex(fields = {"name", "age"})
|
||||
@HashIndex(fields = {"name", "gender"})
|
||||
public class Person {
|
||||
private String name;
|
||||
|
||||
private int age;
|
||||
|
||||
private Gender gender
|
||||
}
|
||||
```
|
|
@ -0,0 +1,161 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Mapping
|
||||
|
||||
In this section we will describe the features and conventions for mapping Java objects to documents and how to override those conventions with annotation based mapping metadata.
|
||||
|
||||
## Conventions
|
||||
|
||||
- The Java class name is mapped to the collection name
|
||||
- The non-static fields of a Java object are used as fields in the stored document
|
||||
- The Java field name is mapped to the stored document field name
|
||||
- All nested Java object are stored as nested objects in the stored document
|
||||
- The Java class needs a constructor which meets the following criteria:
|
||||
- in case of a single constructor:
|
||||
- a non-parameterized constructor or
|
||||
- a parameterized constructor
|
||||
- in case of multiple constructors:
|
||||
- a non-parameterized constructor or
|
||||
- a parameterized constructor annotated with `@PersistenceConstructor`
|
||||
|
||||
## Type conventions
|
||||
|
||||
ArangoDB uses [VelocyPack](https://github.com/arangodb/velocypack) as it's internal storage format which supports a large number of data types. In addition Spring Data ArangoDB offers - with the underlying Java driver - built-in converters to add additional types to the mapping.
|
||||
|
||||
| Java type | VelocyPack type |
|
||||
| ------------------------ | ----------------------------- |
|
||||
| java.lang.String | string |
|
||||
| java.lang.Boolean | bool |
|
||||
| java.lang.Integer | signed int 4 bytes, smallint |
|
||||
| java.lang.Long | signed int 8 bytes, smallint |
|
||||
| java.lang.Short | signed int 2 bytes, smallint |
|
||||
| java.lang.Double | double |
|
||||
| java.lang.Float | double |
|
||||
| java.math.BigInteger | string |
|
||||
| java.math.BigDecimal | string |
|
||||
| java.lang.Number | double |
|
||||
| java.lang.Character | string |
|
||||
| java.util.UUID | string |
|
||||
| java.lang.byte[] | string (Base64) |
|
||||
| java.util.Date | string (date-format ISO 8601) |
|
||||
| java.sql.Date | string (date-format ISO 8601) |
|
||||
| java.sql.Timestamp | string (date-format ISO 8601) |
|
||||
| java.time.Instant | string (date-format ISO 8601) |
|
||||
| java.time.LocalDate | string (date-format ISO 8601) |
|
||||
| java.time.LocalDateTime | string (date-format ISO 8601) |
|
||||
| java.time.OffsetDateTime | string (date-format ISO 8601) |
|
||||
| java.time.ZonedDateTime | string (date-format ISO 8601) |
|
||||
|
||||
## Type mapping
|
||||
|
||||
As collections in ArangoDB can contain documents of various types, a mechanism to retrieve the correct Java class is required. The type information of properties declared in a class may not be enough to restore the original class (due to inheritance). If the declared complex type and the actual type do not match, information about the actual type is stored together with the document. This is necessary to restore the correct type when reading from the DB. Consider the following example:
|
||||
|
||||
```java
|
||||
public class Person {
|
||||
private String name;
|
||||
private Address homeAddress;
|
||||
// ...
|
||||
|
||||
// getters and setters omitted
|
||||
}
|
||||
|
||||
public class Employee extends Person {
|
||||
private Address workAddress;
|
||||
// ...
|
||||
|
||||
// getters and setters omitted
|
||||
}
|
||||
|
||||
public class Address {
|
||||
private final String street;
|
||||
private final String number;
|
||||
// ...
|
||||
|
||||
public Address(String street, String number) {
|
||||
this.street = street;
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
// getters omitted
|
||||
}
|
||||
|
||||
@Document
|
||||
public class Company {
|
||||
@Key
|
||||
private String key;
|
||||
private Person manager;
|
||||
|
||||
// getters and setters omitted
|
||||
}
|
||||
|
||||
Employee manager = new Employee();
|
||||
manager.setName("Jane Roberts");
|
||||
manager.setHomeAddress(new Address("Park Avenue", "432/64"));
|
||||
manager.setWorkAddress(new Address("Main Street", "223"));
|
||||
Company comp = new Company();
|
||||
comp.setManager(manager);
|
||||
```
|
||||
|
||||
The serialized document for the DB looks like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"manager": {
|
||||
"name": "Jane Roberts",
|
||||
"homeAddress": {
|
||||
"street": "Park Avenue",
|
||||
"number": "432/64"
|
||||
},
|
||||
"workAddress": {
|
||||
"street": "Main Street",
|
||||
"number": "223"
|
||||
},
|
||||
"_class": "com.arangodb.Employee"
|
||||
},
|
||||
"_class": "com.arangodb.Company"
|
||||
}
|
||||
```
|
||||
|
||||
Type hints are written for top-level documents (as a collection can contain different document types) as well as for every value if it's a complex type and a sub-type of the property type declared. `Map`s and `Collection`s are excluded from type mapping. Without the additional information about the concrete classes used, the document couldn't be restored in Java. The type information of the `manager` property is not enough to determine the `Employee` type. The `homeAddress` and `workAddress` properties have the same actual and defined type, thus no type hint is needed.
|
||||
|
||||
### Customizing type mapping
|
||||
|
||||
By default, the fully qualified class name is stored in the documents as a type hint. A custom type hint can be set with the `@TypeAlias("my-alias")` annotation on an entity. Make sure that it is an unique identifier across all entities. If we would add a `TypeAlias("employee")` annotation to the `Employee` class above, it would be persisted as `"_class": "employee"`.
|
||||
|
||||
The default type key is `_class` and can be changed by overriding the `typeKey()` method of the `AbstractArangoConfiguration` class.
|
||||
|
||||
If you need to further customize the type mapping process, the `arangoTypeMapper()` method of the configuration class can be overridden. The included `DefaultArangoTypeMapper` can be customized by providing a list of [`TypeInformationMapper`](https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/convert/TypeInformationMapper.html)s that create aliases from types and vice versa.
|
||||
|
||||
In order to fully customize the type mapping process you can provide a custom type mapper implementation by extending the `DefaultArangoTypeMapper` class.
|
||||
|
||||
### Deactivating type mapping
|
||||
|
||||
To deactivate the type mapping process, you can return `null` from the `typeKey()` method of the `AbstractArangoConfiguration` class. No type hints are stored in the documents with this setting. If you make sure that each defined type corresponds to the actual type, you can disable the type mapping, otherwise it can lead to exceptions when reading the entities from the DB.
|
||||
|
||||
## Annotations
|
||||
|
||||
### Annotation overview
|
||||
|
||||
| annotation | level | description |
|
||||
| ----------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| @Document | class | marks this class as a candidate for mapping |
|
||||
| @Edge | class | marks this class as a candidate for mapping |
|
||||
| @Id | field | stores the field as the system field \_key |
|
||||
| @Rev | field | stores the field as the system field \_rev |
|
||||
| @Field("alt-name") | field | stores the field with an alternative name |
|
||||
| @Ref | field | stores the \_id of the referenced document and not the nested document |
|
||||
| @From | field | stores the \_id of the referenced document as the system field \_from |
|
||||
| @To | field | stores the \_id of the referenced document as the system field \_to |
|
||||
| @Relations | field | vertices which are connected over edges |
|
||||
| @Transient | field, method, annotation | marks a field to be transient for the mapping framework, thus the property will not be persisted and not further inspected by the mapping framework |
|
||||
| @PersistenceConstructor | constructor | marks a given constructor - even a package protected one - to use when instantiating the object from the database |
|
||||
| @TypeAlias("alias") | class | set a type alias for the class when persisted to the DB |
|
||||
| @HashIndex | class | describes a hash index |
|
||||
| @HashIndexed | field | describes how to index the field |
|
||||
| @SkiplistIndex | class | describes a skiplist index |
|
||||
| @SkiplistIndexed | field | describes how to index the field |
|
||||
| @PersistentIndex | class | describes a persistent index |
|
||||
| @PersistentIndexed | field | describes how to index the field |
|
||||
| @GeoIndex | class | describes a geo index |
|
||||
| @GeoIndexed | field | describes how to index the field |
|
||||
| @FulltextIndex | class | describes a fulltext index |
|
||||
| @FulltextIndexed | field | describes how to index the field |
|
|
@ -0,0 +1,56 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Reference
|
||||
|
||||
With the annotation `@Ref` applied on a field the nested object isn’t stored as a nested object in the document. The `_id` field of the nested object is stored in the document and the nested object has to be stored as a separate document in another collection described in the `@Document` annotation of the nested object class. To successfully persist an instance of your object the referencing field has to be null or it's instance has to provide a field with the annotation `@Id` including a valid id.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Document(value="persons")
|
||||
public class Person {
|
||||
@Ref
|
||||
private Address address;
|
||||
}
|
||||
|
||||
@Document("addresses")
|
||||
public class Address {
|
||||
@Id
|
||||
private String id;
|
||||
private String country;
|
||||
private String street;
|
||||
}
|
||||
```
|
||||
|
||||
The database representation of `Person` in collection _persons_ looks as follow:
|
||||
|
||||
```
|
||||
{
|
||||
"_key" : "123",
|
||||
"_id" : "persons/123",
|
||||
"address" : "addresses/456"
|
||||
}
|
||||
```
|
||||
|
||||
and the representation of `Address` in collection _addresses_:
|
||||
|
||||
```
|
||||
{
|
||||
"_key" : "456",
|
||||
"_id" : "addresses/456",
|
||||
"country" : "...",
|
||||
"street" : "..."
|
||||
}
|
||||
```
|
||||
|
||||
Without the annotation `@Ref` at the field `address`, the stored document would look:
|
||||
|
||||
```
|
||||
{
|
||||
"_key" : "123",
|
||||
"_id" : "persons/123",
|
||||
"address" : {
|
||||
"country" : "...",
|
||||
"street" : "..."
|
||||
}
|
||||
}
|
||||
```
|
|
@ -0,0 +1,19 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Relations
|
||||
|
||||
With the annotation `@Relations` applied on a collection or array field in a class annotated with `@Document` the nested objects are fetched from the database over a graph traversal with your current object as the starting point. The most relevant parameter is `edge`. With `edge` you define the edge collection - which should be used in the traversal - using the class type. With the parameter `depth` you can define the maximal depth for the traversal (default 1) and the parameter `direction` defines whether the traversal should follow outgoing or incoming edges (default Direction.ANY).
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Document(value="persons")
|
||||
public class Person {
|
||||
@Relations(edge=Relation.class, depth=1, direction=Direction.ANY)
|
||||
private List<Person> friends;
|
||||
}
|
||||
|
||||
@Edge(name="relations")
|
||||
public class Relation {
|
||||
|
||||
}
|
||||
```
|
|
@ -1,778 +1,24 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Spring Data ArangoDB - Reference
|
||||
|
||||
# Template
|
||||
|
||||
With `ArangoTemplate` Spring Data ArangoDB offers a central support for interactions with the database over a rich feature set. It mostly offers the features from the ArangoDB Java driver with additional exception translation from the drivers exceptions to the Spring Data access exceptions inheriting the `DataAccessException` class.
|
||||
The `ArangoTemplate` class is the default implementation of the operations interface `ArangoOperations` which developers of Spring Data are encouraged to code against.
|
||||
|
||||
# Repositories
|
||||
|
||||
## Introduction to repositories
|
||||
|
||||
Spring Data Commons provides a composable repository infrastructure which Spring Data ArangoDB is built on. These allow for interface-based composition of repositories consisting of provided default implementations for certain interfaces (like `CrudRepository`) and custom implementations for other methods.
|
||||
|
||||
## Instantiating
|
||||
|
||||
Instances of a Repository are created in Spring beans through the auto-wired mechanism of Spring.
|
||||
|
||||
```java
|
||||
public class MySpringBean {
|
||||
|
||||
@Autowired
|
||||
private MyRepository rep;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Return types
|
||||
|
||||
The method return type for single results can be a primitive type, a domain class, `Map<String, Object>`, `BaseDocument`, `BaseEdgeDocument`, `Optional<Type>`, `GeoResult<Type>`.
|
||||
The method return type for multiple results can additionally be `ArangoCursor<Type>`, `Iterable<Type>`, `Collection<Type>`, `List<Type>`, `Set<Type>`, `Page<Type>`, `Slice<Type>`, `GeoPage<Type>`, `GeoResults<Type>` where Type can be everything a single result can be.
|
||||
|
||||
## Query methods
|
||||
|
||||
Queries using [ArangoDB Query Language (AQL)](https://docs.arangodb.com/current/AQL/index.html) can be supplied with the `@Query` annotation on methods. `AqlQueryOptions` can also be passed to the driver, as an argument anywhere in the method signature.
|
||||
|
||||
There are three ways of passing bind parameters to the query in the query annotation.
|
||||
|
||||
Using number matching, arguments will be substituted into the query in the order they are passed to the query method.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<Customer, String>{
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @0 AND c.surname == @2 RETURN c")
|
||||
ArangoCursor<Customer> query(String name, AqlQueryOptions options, String surname);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
With the `@Param` annotation, the argument will be placed in the query at the place corresponding to the value passed to the `@Param` annotation.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<Customer, String>{
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @name AND c.surname == @surname RETURN c")
|
||||
ArangoCursor<Customer> query(@Param("name") String name, @Param("surname") String surname);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
In addition you can use a parameter of type `Map<String, Object>` annotated with `@BindVars` as your bind parameters. You can then fill the map with any parameter used in the query. (see [here](https://docs.arangodb.com/3.1/AQL/Fundamentals/BindParameters.html#bind-parameters) for more Information about Bind Parameters).
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<Customer, String>{
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @name AND c.surname = @surname RETURN c")
|
||||
ArangoCursor<Customer> query(@BindVars Map<String, Object> bindVars);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
A mixture of any of these methods can be used. Parameters with the same name from an `@Param` annotation will override those in the `bindVars`.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<Customer, String>{
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @name AND c.surname = @surname RETURN c")
|
||||
ArangoCursor<Customer> query(@BindVars Map<String, Object> bindVars, @Param("name") String name);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Named queries
|
||||
An alternative to using the `@Query` annotation on methods is specifying them in a separate `.properties` file. The default path for the file is `META-INF/arango-named-queries.properties` and can be changed with the `EnableArangoRepositories#namedQueriesLocation()` setting. The entries in the properties file must adhere to the following convention: `{simple entity name}.{method name} = {query}`. Let's assume we have the following repository interface:
|
||||
|
||||
```java
|
||||
package com.arangodb.repository;
|
||||
|
||||
public interface CustomerRepository extends ArangoRepository<Customer> {
|
||||
Customer findByUsername(@Param("username") String username);
|
||||
}
|
||||
```
|
||||
|
||||
The corresponding `arango-named-queries.properties` file looks like this:
|
||||
|
||||
```properties
|
||||
Customer.findByUsername = FOR c IN customers FILTER c.username == @username RETURN c
|
||||
```
|
||||
|
||||
The queries specified in the properties file are no different than the queries that can be defined with the `@Query` annotation. The only difference is that the queries are in one place. If there is a `@Query` annotation present and a named query defined, the query in the `@Query` annotation takes precedence.
|
||||
|
||||
## Derived queries
|
||||
|
||||
Spring Data ArangoDB supports queries derived from methods names by splitting it into its semantic parts and converting into AQL. The mechanism strips the prefixes `find..By`, `get..By`, `query..By`, `read..By`, `stream..By`, `count..By`, `exists..By`, `delete..By`, `remove..By` from the method and parses the rest. The By acts as a separator to indicate the start of the criteria for the query to be built. You can define conditions on entity properties and concatenate them with `And` and `Or`.
|
||||
|
||||
The complete list of part types for derived methods is below, where doc is a document in the database
|
||||
|
||||
Keyword | Sample | Predicate
|
||||
----------|----------------|--------
|
||||
IsGreaterThan, GreaterThan, After | findByAgeGreaterThan(int age) | doc.age > age
|
||||
IsGreaterThanEqual, GreaterThanEqual | findByAgeIsGreaterThanEqual(int age) | doc.age >= age
|
||||
IsLessThan, LessThan, Before | findByAgeIsLessThan(int age) | doc.age < age
|
||||
IsLessThanEqualLessThanEqual | findByAgeLessThanEqual(int age) | doc.age <= age
|
||||
IsBetween, Between | findByAgeBetween(int lower, int upper) | lower < doc.age < upper
|
||||
IsNotNull, NotNull | findByNameNotNull() | doc.name != null
|
||||
IsNull, Null | findByNameNull() | doc.name == null
|
||||
IsLike, Like | findByNameLike(String name) | doc.name LIKE name
|
||||
IsNotLike, NotLike | findByNameNotLike(String name) | NOT(doc.name LIKE name)
|
||||
IsStartingWith, StartingWith, StartsWith | findByNameStartsWith(String prefix) | doc.name LIKE prefix
|
||||
IsEndingWith, EndingWith, EndsWith | findByNameEndingWith(String suffix) | doc.name LIKE suffix
|
||||
Regex, MatchesRegex, Matches | findByNameRegex(String pattern) | REGEX_TEST(doc.name, name, ignoreCase)
|
||||
(No Keyword) | findByFirstName(String name) | doc.name == name
|
||||
IsTrue, True | findByActiveTrue() | doc.active == true
|
||||
IsFalse, False | findByActiveFalse() | doc.active == false
|
||||
Is, Equals | findByAgeEquals(int age) | doc.age == age
|
||||
IsNot, Not | findByAgeNot(int age) | doc.age != age
|
||||
IsIn, In | findByNameIn(String[] names) | doc.name IN names
|
||||
IsNotIn, NotIn | findByNameIsNotIn(String[] names) | doc.name NOT IN names
|
||||
IsContaining, Containing, Contains | findByFriendsContaining(String name) | name IN doc.friends
|
||||
IsNotContaining, NotContaining, NotContains | findByFriendsNotContains(String name) | name NOT IN doc.friends
|
||||
Exists | findByFriendNameExists() | HAS(doc.friend, name)
|
||||
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<Customer, String> {
|
||||
|
||||
// FOR c IN customers FILTER c.name == @0 RETURN c
|
||||
ArangoCursor<Customer> findByName(String name);
|
||||
ArangoCursor<Customer> getByName(String name);
|
||||
|
||||
// FOR c IN customers
|
||||
// FILTER c.name == @0 && c.age == @1
|
||||
// RETURN c
|
||||
ArangoCursor<Customer> findByNameAndAge(String name, int age);
|
||||
|
||||
// FOR c IN customers
|
||||
// FILTER c.name == @0 || c.age == @1
|
||||
// RETURN c
|
||||
ArangoCursor<Customer> findByNameOrAge(String name, int age);
|
||||
}
|
||||
```
|
||||
|
||||
You can apply sorting for one or multiple sort criteria by appending `OrderBy` to the method and `Asc` or `Desc` for the directions.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<Customer, String> {
|
||||
|
||||
// FOR c IN customers
|
||||
// FILTER c.name == @0
|
||||
// SORT c.age DESC RETURN c
|
||||
ArangoCursor<Customer> getByNameOrderByAgeDesc(String name);
|
||||
|
||||
// FOR c IN customers
|
||||
// FILTER c.name = @0
|
||||
// SORT c.name ASC, c.age DESC RETURN c
|
||||
ArangoCursor<Customer> findByNameOrderByNameAscAgeDesc(String name);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
### Geospatial queries
|
||||
|
||||
Geospatial queries are a subsection of derived queries. To use a geospatial query on a collection, a geo index must exist on that collection. A geo index can be created on a field which is a two element array, corresponding to latitude and longitude coordinates.
|
||||
|
||||
As a subsection of derived queries, geospatial queries support all the same return types, but also support the three return types `GeoPage, GeoResult and Georesults`. These types must be used in order to get the distance of each document as generated by the query.
|
||||
|
||||
There are two kinds of geospatial query, Near and Within. Near sorts documents by distance from the given point, while within both sorts and filters documents, returning those within the given distance range or shape.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<City, String> {
|
||||
|
||||
GeoResult<City> getByLocationNear(Point point);
|
||||
|
||||
GeoResults<City> findByLocationWithinOrLocationWithin(Box box, Polygon polygon);
|
||||
|
||||
//Equivalent queries
|
||||
GeoResults<City> findByLocationWithinOrLocationWithin(Point point, int distance);
|
||||
GeoResults<City> findByLocationWithinOrLocationWithin(Point point, Distance distance);
|
||||
GeoResults<City> findByLocationWithinOrLocationWithin(Circle circle);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Property expression
|
||||
|
||||
Property expressions can refer only to direct and nested properties of the managed domain class. The algorithm checks the domain class for the entire expression as the property. If the check fails, the algorithm splits up the expression at the camel case parts from the right and tries to find the corresponding property.
|
||||
|
||||
```java
|
||||
@Document("customers")
|
||||
public class Customer {
|
||||
private Address address;
|
||||
}
|
||||
|
||||
public class Address {
|
||||
private ZipCode zipCode;
|
||||
}
|
||||
|
||||
public interface MyRepository extends Repository<Customer, String> {
|
||||
|
||||
// 1. step: search domain class for a property "addressZipCode"
|
||||
// 2. step: search domain class for "addressZip.code"
|
||||
// 3. step: search domain class for "address.zipCode"
|
||||
ArangoCursor<Customer> findByAddressZipCode(ZipCode zipCode);
|
||||
}
|
||||
```
|
||||
|
||||
It is possible for the algorithm to select the wrong property if the domain class also has a property which matches the first split of the expression. To resolve this ambiguity you can use _ as a separator inside your method-name to define traversal points.
|
||||
|
||||
```java
|
||||
@Document("customers")
|
||||
public class Customer {
|
||||
private Address address;
|
||||
private AddressZip addressZip;
|
||||
}
|
||||
|
||||
public class Address {
|
||||
private ZipCode zipCode;
|
||||
}
|
||||
|
||||
public class AddressZip {
|
||||
private String code;
|
||||
}
|
||||
|
||||
public interface MyRepository extends Repository<Customer, String> {
|
||||
|
||||
// 1. step: search domain class for a property "addressZipCode"
|
||||
// 2. step: search domain class for "addressZip.code"
|
||||
// creates query with "x.addressZip.code"
|
||||
ArangoCursor<Customer> findByAddressZipCode(ZipCode zipCode);
|
||||
|
||||
// 1. step: search domain class for a property "addressZipCode"
|
||||
// 2. step: search domain class for "addressZip.code"
|
||||
// 3. step: search domain class for "address.zipCode"
|
||||
// creates query with "x.address.zipCode"
|
||||
ArangoCursor<Customer> findByAddress_ZipCode(ZipCode zipCode);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Special parameter handling
|
||||
|
||||
### Bind parameters
|
||||
|
||||
AQL supports the usage of [bind parameters](https://docs.arangodb.com/3.1/AQL/Fundamentals/BindParameters.html) which you can define with a method parameter annotated with `@BindVars` of type `Map<String, Object>`.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<Customer, String> {
|
||||
|
||||
@Query("FOR c IN customers FILTER c[@field] == @value RETURN c")
|
||||
ArangoCursor<Customer> query(Map<String, Object> bindVars);
|
||||
|
||||
}
|
||||
|
||||
Map<String, Object> bindVars = new HashMap<String, Object>();
|
||||
bindVars.put("field", "name");
|
||||
bindVars.put("value", "john";
|
||||
|
||||
// will execute query "FOR c IN customers FILTER c.name == "john" RETURN c"
|
||||
ArangoCursor<Customer> cursor = myRepo.query(bindVars);
|
||||
```
|
||||
|
||||
### AQL query options
|
||||
|
||||
You can set additional options for the query and the created cursor over the class `AqlQueryOptions` which you can simply define as a method parameter without a specific name. AqlQuery options can also be defined with the `@QueryOptions` annotation, as shown below. AqlQueryOptions from an annotation and those from an argument are merged if both exist, with those in the argument taking precedence.
|
||||
|
||||
The `AqlQueryOptions` allows you to set the cursor time-to-live, batch-size, caching flag and several other settings. This special parameter works with both query-methods and finder-methods. Keep in mind that some options, like time-to-live, are only effective if the method return type is`ArangoCursor<T>` or `Iterable<T>`.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<Customer, String> {
|
||||
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @0 RETURN c")
|
||||
Iterable<Customer> query(String name, AqlQueryOptions options);
|
||||
|
||||
|
||||
Iterable<Customer> findByName(String name, AqlQueryOptions options);
|
||||
|
||||
|
||||
@QueryOptions(maxPlans = 1000, ttl = 128)
|
||||
ArangoCursor<Customer> findByAddressZipCode(ZipCode zipCode);
|
||||
|
||||
|
||||
@Query("FOR c IN customers FILTER c[@field] == @value RETURN c")
|
||||
@QueryOptions(cache = true, ttl = 128)
|
||||
ArangoCursor<Customer> query(Map<String, Object> bindVars, AqlQueryOptions options);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
### Paging and sorting
|
||||
|
||||
Spring Data ArangoDB supports Spring Data's `Pageable` and `Sort` parameters for repository query methods. If these parameters are used together with a native query, either through `@Query` annotation or named queries, a placeholder must be specified:
|
||||
- `#pageable` for `Pageable` parameter
|
||||
- `#sort` for `Sort` parameter
|
||||
|
||||
Sort properties or paths are attributes separated by dots (e.g. `customer.age`). Some rules apply for them:
|
||||
- they must not begin or end with a dot (e.g. `.customer.age`)
|
||||
- dots in attributes are supported, but the whole attribute must be enclosed by backticks (e.g. ``customer.`attr.with.dots` ``
|
||||
- backticks in attributes are supported, but they must be escaped with a backslash (e.g. ``customer.attr_with\` ``)
|
||||
- any backslashes (that do not escape a backtick) are escaped (e.g. `customer\` => `customer\\`)
|
||||
|
||||
```
|
||||
just.`some`.`attributes.that`.`form\``.a path\`.\ is converted to
|
||||
`just`.`some`.`attributes.that`.`form\``.`a path\``.`\\`
|
||||
```
|
||||
|
||||
Native queries example:
|
||||
```java
|
||||
public interface CustomerRepository extends ArangoRepository<Customer> {
|
||||
|
||||
@Query("FOR c IN customer FILTER c.name == @1 #pageable RETURN c")
|
||||
Page<Customer> findByNameNative(Pageable pageable, String name);
|
||||
|
||||
@Query("FOR c IN customer FILTER c.name == @1 #sort RETURN c")
|
||||
List<Customer> findByNameNative(Sort sort, String name);
|
||||
}
|
||||
|
||||
// don't forget to specify the var name of the document
|
||||
final Pageable page = PageRequest.of(1, 10, Sort.by("c.age"));
|
||||
repository.findByNameNative(page, "Matt");
|
||||
|
||||
final Sort sort = Sort.by(Direction.DESC, "c.age");
|
||||
repository.findByNameNative(sort, "Tony");
|
||||
```
|
||||
|
||||
Derived queries example:
|
||||
```java
|
||||
public interface CustomerRepository extends ArangoRepository<Customer> {
|
||||
|
||||
Page<Customer> findByName(Pageable pageable, String name);
|
||||
|
||||
List<Customer> findByName(Sort sort, String name);
|
||||
}
|
||||
|
||||
// no var name is necessary for derived queries
|
||||
final Pageable page = PageRequest.of(1, 10, Sort.by("age"));
|
||||
repository.findByName(page, "Matt");
|
||||
|
||||
final Sort sort = Sort.by(Direction.DESC, "age");
|
||||
repository.findByName(sort, "Tony");
|
||||
```
|
||||
|
||||
# Mapping
|
||||
|
||||
## Introduction to mapping
|
||||
|
||||
In this section we will describe the features and conventions for mapping Java objects to documents and how to override those conventions with annotation based mapping metadata.
|
||||
|
||||
## Conventions
|
||||
|
||||
* The Java class name is mapped to the collection name
|
||||
* The non-static fields of a Java object are used as fields in the stored document
|
||||
* The Java field name is mapped to the stored document field name
|
||||
* All nested Java object are stored as nested objects in the stored document
|
||||
* The Java class needs a constructor which meets the following criteria:
|
||||
* in case of a single constructor:
|
||||
* a non-parameterized constructor or
|
||||
* a parameterized constructor
|
||||
* in case of multiple constructors:
|
||||
* a non-parameterized constructor or
|
||||
* a parameterized constructor annotated with `@PersistenceConstructor`
|
||||
|
||||
## Type conventions
|
||||
|
||||
ArangoDB uses [VelocyPack](https://github.com/arangodb/velocypack) as it's internal storage format which supports a large number of data types. In addition Spring Data ArangoDB offers - with the underlying Java driver - built-in converters to add additional types to the mapping.
|
||||
|
||||
Java type | VelocyPack type
|
||||
----------|----------------
|
||||
java.lang.String | string
|
||||
java.lang.Boolean | bool
|
||||
java.lang.Integer | signed int 4 bytes, smallint
|
||||
java.lang.Long | signed int 8 bytes, smallint
|
||||
java.lang.Short | signed int 2 bytes, smallint
|
||||
java.lang.Double | double
|
||||
java.lang.Float | double
|
||||
java.math.BigInteger | signed int 8 bytes, unsigned int 8 bytes
|
||||
java.math.BigDecimal | double
|
||||
java.lang.Number | double
|
||||
java.lang.Character | string
|
||||
java.util.Date | string (date-format ISO 8601)
|
||||
java.sql.Date | string (date-format ISO 8601)
|
||||
java.sql.Timestamp | string (date-format ISO 8601)
|
||||
java.util.UUID | string
|
||||
java.lang.byte[] | string (Base64)
|
||||
|
||||
## Type mapping
|
||||
As collections in ArangoDB can contain documents of various types, a mechanism to retrieve the correct Java class is required. The type information of properties declared in a class may not be enough to restore the original class (due to inheritance). If the declared complex type and the actual type do not match, information about the actual type is stored together with the document. This is necessary to restore the correct type when reading from the DB. Consider the following example:
|
||||
|
||||
```java
|
||||
public class Person {
|
||||
private String name;
|
||||
private Address homeAddress;
|
||||
// ...
|
||||
|
||||
// getters and setters omitted
|
||||
}
|
||||
|
||||
public class Employee extends Person {
|
||||
private Address workAddress;
|
||||
// ...
|
||||
|
||||
// getters and setters omitted
|
||||
}
|
||||
|
||||
public class Address {
|
||||
private final String street;
|
||||
private final String number;
|
||||
// ...
|
||||
|
||||
public Address(String street, String number) {
|
||||
this.street = street;
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
// getters omitted
|
||||
}
|
||||
|
||||
@Document
|
||||
public class Company {
|
||||
@Key
|
||||
private String key;
|
||||
private Person manager;
|
||||
|
||||
// getters and setters omitted
|
||||
}
|
||||
|
||||
Employee manager = new Employee();
|
||||
manager.setName("Jane Roberts");
|
||||
manager.setHomeAddress(new Address("Park Avenue", "432/64"));
|
||||
manager.setWorkAddress(new Address("Main Street", "223"));
|
||||
Company comp = new Company();
|
||||
comp.setManager(manager);
|
||||
```
|
||||
|
||||
The serialized document for the DB looks like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"manager": {
|
||||
"name": "Jane Roberts",
|
||||
"homeAddress": {
|
||||
"street": "Park Avenue",
|
||||
"number": "432/64"
|
||||
},
|
||||
"workAddress": {
|
||||
"street": "Main Street",
|
||||
"number": "223"
|
||||
},
|
||||
"_class": "com.arangodb.Employee"
|
||||
},
|
||||
"_class": "com.arangodb.Company"
|
||||
}
|
||||
```
|
||||
|
||||
Type hints are written for top-level documents (as a collection can contain different document types) as well as for every value if it's a complex type and a sub-type of the property type declared. `Map`s and `Collection`s are excluded from type mapping. Without the additional information about the concrete classes used, the document couldn't be restored in Java. The type information of the `manager` property is not enough to determine the `Employee` type. The `homeAddress` and `workAddress` properties have the same actual and defined type, thus no type hint is needed.
|
||||
|
||||
### Customizing type mapping
|
||||
By default, the fully qualified class name is stored in the documents as a type hint. A custom type hint can be set with the `@TypeAlias("my-alias")` annotation on an entity. Make sure that it is an unique identifier across all entities. If we would add a `TypeAlias("employee")` annotation to the `Employee` class above, it would be persisted as `"_class": "employee"`.
|
||||
|
||||
The default type key is `_class` and can be changed by overriding the `typeKey()` method of the `AbstractArangoConfiguration` class.
|
||||
|
||||
If you need to further customize the type mapping process, the `arangoTypeMapper()` method of the configuration class can be overridden. The included `DefaultArangoTypeMapper` can be customized by providing a list of [`TypeInformationMapper`](https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/convert/TypeInformationMapper.html)s that create aliases from types and vice versa.
|
||||
|
||||
In order to fully customize the type mapping process you can provide a custom type mapper implementation by extending the `DefaultArangoTypeMapper` class.
|
||||
|
||||
### Deactivating type mapping
|
||||
To deactivate the type mapping process, you can return `null` from the `typeKey()` method of the `AbstractArangoConfiguration` class. No type hints are stored in the documents with this setting. If you make sure that each defined type corresponds to the actual type, you can disable the type mapping, otherwise it can lead to exceptions when reading the entities from the DB.
|
||||
|
||||
## Annotations
|
||||
|
||||
### Annotation overview
|
||||
|
||||
annotation | level | description
|
||||
-----------|-------|------------
|
||||
@Document | class | marks this class as a candidate for mapping
|
||||
@Edge | class | marks this class as a candidate for mapping
|
||||
@Id | field | stores the field as the system field _id
|
||||
@Key | field | stores the field as the system field _key
|
||||
@Rev | field | stores the field as the system field _rev
|
||||
@Field("alt-name") | field | stores the field with an alternative name
|
||||
@Ref | field | stores the _id of the referenced document and not the nested document
|
||||
@From | field | stores the _id of the referenced document as the system field _from
|
||||
@To | field | stores the _id of the referenced document as the system field _to
|
||||
@Relations | field | vertices which are connected over edges
|
||||
@Transient | field, method, annotation | marks a field to be transient for the mapping framework, thus the property will not be persisted and not further inspected by the mapping framework
|
||||
@PersistenceConstructor | constructor | marks a given constructor - even a package protected one - to use when instantiating the object from the database
|
||||
@TypeAlias("alias") | class | set a type alias for the class when persisted to the DB
|
||||
@HashIndex | class | describes a hash index
|
||||
@HashIndexed | field | describes how to index the field
|
||||
@SkiplistIndex | class | describes a skiplist index
|
||||
@SkiplistIndexed | field | describes how to index the field
|
||||
@PersistentIndex | class | describes a persistent index
|
||||
@PersistentIndexed | field | describes how to index the field
|
||||
@GeoIndex | class | describes a geo index
|
||||
@GeoIndexed | field | describes how to index the field
|
||||
@FulltextIndex | class | describes a fulltext index
|
||||
@FulltextIndexed | field | describes how to index the field
|
||||
|
||||
### Document
|
||||
|
||||
The annotations `@Document` applied to a class marks this class as a candidate for mapping to the database. The most relevant parameter is `value` to specify the collection name in the database. The annotation `@Document` specifies the collection type to `DOCUMENT`.
|
||||
|
||||
```java
|
||||
@Document(value="persons")
|
||||
public class Person {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Edge
|
||||
|
||||
The annotations `@Edge` applied to a class marks this class as a candidate for mapping to the database. The most relevant parameter is `value` to specify the collection name in the database. The annotation `@Edge` specifies the collection type to `EDGE`.
|
||||
|
||||
```java
|
||||
@Edge("relations")
|
||||
public class Relation {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Reference
|
||||
|
||||
With the annotation `@Ref` applied on a field the nested object isn’t stored as a nested object in the document. The `_id` field of the nested object is stored in the document and the nested object has to be stored as a separate document in another collection described in the `@Document` annotation of the nested object class. To successfully persist an instance of your object the referencing field has to be null or it's instance has to provide a field with the annotation `@Id` including a valid id.
|
||||
|
||||
```java
|
||||
@Document(value="persons")
|
||||
public class Person {
|
||||
@Ref
|
||||
private Address address;
|
||||
}
|
||||
|
||||
@Document("addresses")
|
||||
public class Address {
|
||||
@Id
|
||||
private String id;
|
||||
private String country;
|
||||
private String street;
|
||||
}
|
||||
```
|
||||
|
||||
The database representation of `Person` in collection *persons* looks as follow:
|
||||
|
||||
```
|
||||
{
|
||||
"_key" : "123",
|
||||
"_id" : "persons/123",
|
||||
"address" : "addresses/456"
|
||||
}
|
||||
```
|
||||
and the representation of `Address` in collection *addresses*:
|
||||
```
|
||||
{
|
||||
"_key" : "456",
|
||||
"_id" : "addresses/456",
|
||||
"country" : "...",
|
||||
"street" : "..."
|
||||
}
|
||||
```
|
||||
|
||||
Without the annotation `@Ref` at the field `address`, the stored document would look:
|
||||
|
||||
```
|
||||
{
|
||||
"_key" : "123",
|
||||
"_id" : "persons/123",
|
||||
"address" : {
|
||||
"country" : "...",
|
||||
"street" : "..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Relations
|
||||
|
||||
With the annotation `@Relations` applied on a collection or array field in a class annotated with `@Document` the nested objects are fetched from the database over a graph traversal with your current object as the starting point. The most relevant parameter is `edge`. With `edge` you define the edge collection - which should be used in the traversal - using the class type. With the parameter `depth` you can define the maximal depth for the traversal (default 1) and the parameter `direction` defines whether the traversal should follow outgoing or incoming edges (default Direction.ANY).
|
||||
|
||||
```java
|
||||
@Document(value="persons")
|
||||
public class Person {
|
||||
@Relations(edge=Relation.class, depth=1, direction=Direction.ANY)
|
||||
private List<Person> friends;
|
||||
}
|
||||
|
||||
@Edge(name="relations")
|
||||
public class Relation {
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
### Document with From and To
|
||||
|
||||
With the annotations `@From` and `@To` applied on a collection or array field in a class annotated with `@Document` the nested edge objects are fetched from the database. Each of the nested edge objects has to be stored as separate edge document in the edge collection described in the `@Edge` annotation of the nested object class with the *_id* of the parent document as field *_from* or *_to*.
|
||||
|
||||
```java
|
||||
@Document("persons")
|
||||
public class Person {
|
||||
@From
|
||||
private List<Relation> relations;
|
||||
}
|
||||
|
||||
@Edge(name="relations")
|
||||
public class Relation {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
The database representation of `Person` in collection *persons* looks as follow:
|
||||
```
|
||||
{
|
||||
"_key" : "123",
|
||||
"_id" : "persons/123"
|
||||
}
|
||||
```
|
||||
|
||||
and the representation of `Relation` in collection *relations*:
|
||||
```
|
||||
{
|
||||
"_key" : "456",
|
||||
"_id" : "relations/456",
|
||||
"_from" : "persons/123"
|
||||
"_to" : ".../..."
|
||||
}
|
||||
{
|
||||
"_key" : "789",
|
||||
"_id" : "relations/456",
|
||||
"_from" : "persons/123"
|
||||
"_to" : ".../..."
|
||||
}
|
||||
...
|
||||
|
||||
```
|
||||
|
||||
### Edge with From and To
|
||||
|
||||
With the annotations `@From` and `@To` applied on a field in a class annotated with `@Edge` the nested object is fetched from the database. The nested object has to be stored as a separate document in the collection described in the `@Document` annotation of the nested object class. The *_id* field of this nested object is stored in the fields `_from` or `_to` within the edge document.
|
||||
|
||||
```java
|
||||
@Edge("relations")
|
||||
public class Relation {
|
||||
@From
|
||||
private Person c1;
|
||||
@To
|
||||
private Person c2;
|
||||
}
|
||||
|
||||
@Document(value="persons")
|
||||
public class Person {
|
||||
@Id
|
||||
private String id;
|
||||
}
|
||||
```
|
||||
|
||||
The database representation of `Relation` in collection *relations* looks as follow:
|
||||
```
|
||||
{
|
||||
"_key" : "123",
|
||||
"_id" : "relations/123",
|
||||
"_from" : "persons/456",
|
||||
"_to" : "persons/789"
|
||||
}
|
||||
```
|
||||
|
||||
and the representation of `Person` in collection *persons*:
|
||||
```
|
||||
{
|
||||
"_key" : "456",
|
||||
"_id" : "persons/456",
|
||||
}
|
||||
{
|
||||
"_key" : "789",
|
||||
"_id" : "persons/789",
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** If you want to save an instance of `Relation`, both `Person` objects (from & to) already have to be persisted and the class `Person` needs a field with the annotation `@Id` so it can hold the persisted `_id` from the database.
|
||||
|
||||
### Index and Indexed annotations
|
||||
|
||||
With the `@<IndexType>Indexed` annotations user defined indexes can be created at a collection level by annotating single fields of a class.
|
||||
|
||||
Possible `@<IndexType>Indexed` annotations are:
|
||||
* `@HashIndexed`
|
||||
* `@SkiplistIndexed`
|
||||
* `@PersistentIndexed`
|
||||
* `@GeoIndexed`
|
||||
* `@FulltextIndexed`
|
||||
|
||||
The following example creates a hash index on the field `name` and a separate hash index on the field `age`:
|
||||
```java
|
||||
public class Person {
|
||||
@HashIndexed
|
||||
private String name;
|
||||
|
||||
@HashIndexed
|
||||
private int age;
|
||||
}
|
||||
```
|
||||
|
||||
With the `@<IndexType>Indexed` annotations different indexes can be created on the same field.
|
||||
|
||||
The following example creates a hash index and also a skiplist index on the field `name`:
|
||||
```java
|
||||
public class Person {
|
||||
@HashIndexed
|
||||
@SkiplistIndexed
|
||||
private String name;
|
||||
}
|
||||
```
|
||||
|
||||
If the index should include multiple fields the `@<IndexType>Index` annotations can be used on the type instead.
|
||||
|
||||
Possible `@<IndexType>Index` annotations are:
|
||||
* `@HashIndex`
|
||||
* `@SkiplistIndex`
|
||||
* `@PersistentIndex`
|
||||
* `@GeoIndex`
|
||||
* `@FulltextIndex`
|
||||
|
||||
The following example creates a single hash index on the fields `name` and `age`, note that if a field is renamed in the database with @Field, the new field name must be used in the index declaration:
|
||||
```java
|
||||
@HashIndex(fields = {"fullname", "age"})
|
||||
public class Person {
|
||||
@Field("fullname")
|
||||
private String name;
|
||||
|
||||
private int age;
|
||||
}
|
||||
```
|
||||
|
||||
The `@<IndexType>Index` annotations can also be used to create an index on a nested field.
|
||||
|
||||
The following example creates a single hash index on the fields `name` and `address.country`:
|
||||
```java
|
||||
@HashIndex(fields = {"name", "address.country"})
|
||||
public class Person {
|
||||
private String name;
|
||||
|
||||
private Address address;
|
||||
}
|
||||
```
|
||||
|
||||
The `@<IndexType>Index` annotations and the `@<IndexType>Indexed` annotations can be used at the same time in one class.
|
||||
|
||||
The following example creates a hash index on the fields `name` and `age` and a separate hash index on the field `age`:
|
||||
```java
|
||||
@HashIndex(fields = {"name", "age"})
|
||||
public class Person {
|
||||
private String name;
|
||||
|
||||
@HashIndexed
|
||||
private int age;
|
||||
}
|
||||
```
|
||||
|
||||
The `@<IndexType>Index` annotations can be used multiple times to create more than one index in this way.
|
||||
|
||||
The following example creates a hash index on the fields `name` and `age` and a separate hash index on the fields `name` and `gender`:
|
||||
```java
|
||||
@HashIndex(fields = {"name", "age"})
|
||||
@HashIndex(fields = {"name", "gender"})
|
||||
public class Person {
|
||||
private String name;
|
||||
|
||||
private int age;
|
||||
|
||||
private Gender gender
|
||||
}
|
||||
```
|
||||
- [Template](Template/README.md)
|
||||
- [Queries](Template/Queries.md)
|
||||
- [Document Manipulation](Template/DocumentManipulation.md)
|
||||
- [Multiple Document Manipulation](Template/MultiDocumentManipulation.md)
|
||||
- [Collection Manipulation](Template/CollectionManipulation.md)
|
||||
- [Repositories](Repositories/README.md)
|
||||
- [Queries](Repositories/Queries/README.md)
|
||||
- [Derived queries](Repositories/Queries/DerivedQueries.md)
|
||||
- [Query methods](Repositories/Queries/QueryMethods.md)
|
||||
- [Named queries](Repositories/Queries/NamedQueries.md)
|
||||
- [Document Manipulation](Repositories/DocumentManipulation.md)
|
||||
- [Multiple Document Manipulation](Repositories/MultiDocumentManipulation.md)
|
||||
- [Query by example](Repositories/QueryByExample.md)
|
||||
- [Mapping](Mapping/README.md)
|
||||
- [Document](Mapping/Document.md)
|
||||
- [Edge](Mapping/Edge.md)
|
||||
- [Reference](Mapping/Reference.md)
|
||||
- [Relations](Mapping/Relations.md)
|
||||
- [Indexes](Mapping/Indexes.md)
|
||||
- [Converter](Mapping/Converter.md)
|
||||
- [Events](Mapping/Events.md)
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Manipulating documents
|
||||
|
||||
## ArangoRepository.existsById
|
||||
|
||||
```
|
||||
ArangoRepository.existsById(ID id) : boolean
|
||||
```
|
||||
|
||||
Returns whether an entity with the given id exists.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **id**: `ID`
|
||||
|
||||
The id (`_key`) of the document. Must not be `null`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
boolean exists = repository.existsById("some-id");
|
||||
```
|
||||
|
||||
## ArangoRepository.findById
|
||||
|
||||
```
|
||||
ArangoRepository.findById(ID id) : Optional<T>
|
||||
```
|
||||
|
||||
Retrieves an entity by its id.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **id**: `ID`
|
||||
|
||||
The id (`_key`) of the document. Must not be `null`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
Optional<MyDomainClass> entity = repository.findById("some-id");
|
||||
```
|
||||
|
||||
## ArangoRepository.save
|
||||
|
||||
```
|
||||
ArangoRepository.save(S entity) : S
|
||||
```
|
||||
|
||||
Saves a given entity. Use the returned instance for further operations as the save operation might have changed the entity instance completely.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **entity**: `S`
|
||||
|
||||
The entity to save in the database. Must not be `null`.
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
MyDomainClass entity = new MyDomainClass();
|
||||
entity = repository.save(entity);
|
||||
```
|
||||
|
||||
## ArangoRepository.deleteById
|
||||
|
||||
```
|
||||
ArangoRepository.deleteById(ID id) : void
|
||||
```
|
||||
|
||||
Deletes the entity with the given id.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **id**: `ID`
|
||||
|
||||
The id (`_key`) of the document. Must not be `null`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
repository.deleteById("some-id");
|
||||
```
|
||||
|
||||
## ArangoRepository.delete
|
||||
|
||||
```
|
||||
ArangoRepository.delete(T entity) : void
|
||||
```
|
||||
|
||||
Deletes a given entity.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **entity**: `T`
|
||||
|
||||
The entity to delete. Must not be `null`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
MyDomainClass entity = ...
|
||||
repository.delete(entity);
|
||||
```
|
|
@ -0,0 +1,106 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Manipulating multiple documents
|
||||
|
||||
## ArangoRepository.findAll
|
||||
|
||||
```
|
||||
ArangoRepository.findAll() : Iterable<T>
|
||||
```
|
||||
|
||||
Returns all instances of the type.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
Iterable<MyDomainClass> entities = repository.findAll();
|
||||
```
|
||||
|
||||
## ArangoRepository.findAllById
|
||||
|
||||
```
|
||||
ArangoRepository.findAllById(Iterable<ID> ids) : Iterable<T>
|
||||
```
|
||||
|
||||
Returns all instances of the type with the given IDs.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **ids**: `Iterable<ID>`
|
||||
|
||||
The ids (`_keys`) of the documents
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
Iterable<MyDomainClass> entities = repository.findAllById(Arrays.asList("some-id", "some-other-id"));
|
||||
```
|
||||
|
||||
## ArangoRepository.saveAll
|
||||
|
||||
```
|
||||
ArangoRepository.saveAll(Iterable<S> entities) : Iterable<S>
|
||||
```
|
||||
|
||||
Saves all given entities.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **entities**: `Iterable<S>`
|
||||
|
||||
A list of entities to save.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
MyDomainClass obj1 = ...
|
||||
MyDomainClass obj2 = ...
|
||||
MyDomainClass obj3 = ...
|
||||
repository.saveAll(Arrays.asList(obj1, obj2, obj3))
|
||||
```
|
||||
|
||||
## ArangoRepository.deleteAll (method 1)
|
||||
|
||||
```
|
||||
ArangoRepository.deleteAll() : void
|
||||
```
|
||||
|
||||
Deletes all entities managed by the repository.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
repository.deleteAll();
|
||||
```
|
||||
|
||||
## ArangoRepository.deleteAll (method 2)
|
||||
|
||||
```
|
||||
ArangoRepository.deleteAll(Iterable<? extends T> entities) : void
|
||||
```
|
||||
|
||||
Deletes the given entities.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **entities**: `Iterable<? extends T>`
|
||||
|
||||
The entities to delete.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
MyDomainClass obj1 = ...
|
||||
MyDomainClass obj2 = ...
|
||||
MyDomainClass obj3 = ...
|
||||
repository.deleteAll(Arrays.asList(obj1, obj2, obj3))
|
||||
```
|
|
@ -0,0 +1,157 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Derived queries
|
||||
|
||||
## Semantic parts
|
||||
|
||||
Spring Data ArangoDB supports queries derived from methods names by splitting it into its semantic parts and converting into AQL. The mechanism strips the prefixes `find..By`, `get..By`, `query..By`, `read..By`, `stream..By`, `count..By`, `exists..By`, `delete..By`, `remove..By` from the method and parses the rest. The `By` acts as a separator to indicate the start of the criteria for the query to be built. You can define conditions on entity properties and concatenate them with `And` and `Or`.
|
||||
|
||||
The complete list of part types for derived methods is below, where `doc` is a document in the database
|
||||
|
||||
| Keyword | Sample | Predicate |
|
||||
| ------------------------------------------- | -------------------------------------- | -------------------------------------- |
|
||||
| IsGreaterThan, GreaterThan, After | findByAgeGreaterThan(int age) | doc.age > age |
|
||||
| IsGreaterThanEqual, GreaterThanEqual | findByAgeIsGreaterThanEqual(int age) | doc.age >= age |
|
||||
| IsLessThan, LessThan, Before | findByAgeIsLessThan(int age) | doc.age < age |
|
||||
| IsLessThanEqualLessThanEqual | findByAgeLessThanEqual(int age) | doc.age <= age |
|
||||
| IsBetween, Between | findByAgeBetween(int lower, int upper) | lower < doc.age < upper |
|
||||
| IsNotNull, NotNull | findByNameNotNull() | doc.name != null |
|
||||
| IsNull, Null | findByNameNull() | doc.name == null |
|
||||
| IsLike, Like | findByNameLike(String name) | doc.name LIKE name |
|
||||
| IsNotLike, NotLike | findByNameNotLike(String name) | NOT(doc.name LIKE name) |
|
||||
| IsStartingWith, StartingWith, StartsWith | findByNameStartsWith(String prefix) | doc.name LIKE prefix |
|
||||
| IsEndingWith, EndingWith, EndsWith | findByNameEndingWith(String suffix) | doc.name LIKE suffix |
|
||||
| Regex, MatchesRegex, Matches | findByNameRegex(String pattern) | REGEX_TEST(doc.name, name, ignoreCase) |
|
||||
| (No Keyword) | findByFirstName(String name) | doc.name == name |
|
||||
| IsTrue, True | findByActiveTrue() | doc.active == true |
|
||||
| IsFalse, False | findByActiveFalse() | doc.active == false |
|
||||
| Is, Equals | findByAgeEquals(int age) | doc.age == age |
|
||||
| IsNot, Not | findByAgeNot(int age) | doc.age != age |
|
||||
| IsIn, In | findByNameIn(String[] names) | doc.name IN names |
|
||||
| IsNotIn, NotIn | findByNameIsNotIn(String[] names) | doc.name NOT IN names |
|
||||
| IsContaining, Containing, Contains | findByFriendsContaining(String name) | name IN doc.friends |
|
||||
| IsNotContaining, NotContaining, NotContains | findByFriendsNotContains(String name) | name NOT IN doc.friends |
|
||||
| Exists | findByFriendNameExists() | HAS(doc.friend, name) |
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
public interface MyRepository extends ArangoRepository<Customer, String> {
|
||||
|
||||
// FOR c IN customers FILTER c.name == @0 RETURN c
|
||||
ArangoCursor<Customer> findByName(String name);
|
||||
ArangoCursor<Customer> getByName(String name);
|
||||
|
||||
// FOR c IN customers
|
||||
// FILTER c.name == @0 && c.age == @1
|
||||
// RETURN c
|
||||
ArangoCursor<Customer> findByNameAndAge(String name, int age);
|
||||
|
||||
// FOR c IN customers
|
||||
// FILTER c.name == @0 || c.age == @1
|
||||
// RETURN c
|
||||
ArangoCursor<Customer> findByNameOrAge(String name, int age);
|
||||
}
|
||||
```
|
||||
|
||||
You can apply sorting for one or multiple sort criteria by appending `OrderBy` to the method and `Asc` or `Desc` for the directions.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends ArangoRepository<Customer, String> {
|
||||
|
||||
// FOR c IN customers
|
||||
// FILTER c.name == @0
|
||||
// SORT c.age DESC RETURN c
|
||||
ArangoCursor<Customer> getByNameOrderByAgeDesc(String name);
|
||||
|
||||
// FOR c IN customers
|
||||
// FILTER c.name = @0
|
||||
// SORT c.name ASC, c.age DESC RETURN c
|
||||
ArangoCursor<Customer> findByNameOrderByNameAscAgeDesc(String name);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Property expression
|
||||
|
||||
Property expressions can refer only to direct and nested properties of the managed domain class. The algorithm checks the domain class for the entire expression as the property. If the check fails, the algorithm splits up the expression at the camel case parts from the right and tries to find the corresponding property.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Document("customers")
|
||||
public class Customer {
|
||||
private Address address;
|
||||
}
|
||||
|
||||
public class Address {
|
||||
private ZipCode zipCode;
|
||||
}
|
||||
|
||||
public interface MyRepository extends ArangoRepository<Customer, String> {
|
||||
|
||||
// 1. step: search domain class for a property "addressZipCode"
|
||||
// 2. step: search domain class for "addressZip.code"
|
||||
// 3. step: search domain class for "address.zipCode"
|
||||
ArangoCursor<Customer> findByAddressZipCode(ZipCode zipCode);
|
||||
}
|
||||
```
|
||||
|
||||
It is possible for the algorithm to select the wrong property if the domain class also has a property which matches the first split of the expression. To resolve this ambiguity you can use `_` as a separator inside your method-name to define traversal points.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Document("customers")
|
||||
public class Customer {
|
||||
private Address address;
|
||||
private AddressZip addressZip;
|
||||
}
|
||||
|
||||
public class Address {
|
||||
private ZipCode zipCode;
|
||||
}
|
||||
|
||||
public class AddressZip {
|
||||
private String code;
|
||||
}
|
||||
|
||||
public interface MyRepository extends ArangoRepository<Customer, String> {
|
||||
|
||||
// 1. step: search domain class for a property "addressZipCode"
|
||||
// 2. step: search domain class for "addressZip.code"
|
||||
// creates query with "x.addressZip.code"
|
||||
ArangoCursor<Customer> findByAddressZipCode(ZipCode zipCode);
|
||||
|
||||
// 1. step: search domain class for a property "addressZipCode"
|
||||
// 2. step: search domain class for "addressZip.code"
|
||||
// 3. step: search domain class for "address.zipCode"
|
||||
// creates query with "x.address.zipCode"
|
||||
ArangoCursor<Customer> findByAddress_ZipCode(ZipCode zipCode);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Geospatial queries
|
||||
|
||||
Geospatial queries are a subsection of derived queries. To use a geospatial query on a collection, a geo index must exist on that collection. A geo index can be created on a field which is a two element array, corresponding to latitude and longitude coordinates.
|
||||
|
||||
As a subsection of derived queries, geospatial queries support all the same return types, but also support the three return types `GeoPage, GeoResult and Georesults`. These types must be used in order to get the distance of each document as generated by the query.
|
||||
|
||||
There are two kinds of geospatial query, Near and Within. Near sorts documents by distance from the given point, while within both sorts and filters documents, returning those within the given distance range or shape.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
public interface MyRepository extends ArangoRepository<City, String> {
|
||||
|
||||
GeoResult<City> getByLocationNear(Point point);
|
||||
|
||||
GeoResults<City> findByLocationWithinOrLocationWithin(Box box, Polygon polygon);
|
||||
|
||||
//Equivalent queries
|
||||
GeoResults<City> findByLocationWithinOrLocationWithin(Point point, int distance);
|
||||
GeoResults<City> findByLocationWithinOrLocationWithin(Point point, Distance distance);
|
||||
GeoResults<City> findByLocationWithinOrLocationWithin(Circle circle);
|
||||
|
||||
}
|
||||
```
|
|
@ -0,0 +1,22 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Named queries
|
||||
|
||||
An alternative to using the `@Query` annotation on methods is specifying them in a separate `.properties` file. The default path for the file is `META-INF/arango-named-queries.properties` and can be changed with the `EnableArangoRepositories#namedQueriesLocation()` setting. The entries in the properties file must adhere to the following convention: `{simple entity name}.{method name} = {query}`. Let's assume we have the following repository interface:
|
||||
|
||||
```java
|
||||
package com.arangodb.repository;
|
||||
|
||||
public interface CustomerRepository extends ArangoRepository<Customer, String> {
|
||||
|
||||
Customer findByUsername(@Param("username") String username);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The corresponding `arango-named-queries.properties` file looks like this:
|
||||
|
||||
```properties
|
||||
Customer.findByUsername = FOR c IN customers FILTER c.username == @username RETURN c
|
||||
```
|
||||
|
||||
The queries specified in the properties file are no different than the queries that can be defined with the `@Query` annotation. The only difference is that the queries are in one place. If there is a `@Query` annotation present and a named query defined, the query in the `@Query` annotation takes precedence.
|
|
@ -0,0 +1,71 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Query methods
|
||||
|
||||
Queries using [ArangoDB Query Language (AQL)](https://docs.arangodb.com/current/AQL/index.html) can be supplied with the `@Query` annotation on methods.
|
||||
|
||||
## Passing bind parameters
|
||||
|
||||
There are three ways of passing bind parameters to the query in the query annotation.
|
||||
|
||||
### Number matching
|
||||
|
||||
Using number matching, arguments will be substituted into the query in the order they are passed to the query method.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends ArangoRepository<Customer, String>{
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @0 AND c.surname == @1 RETURN c")
|
||||
ArangoCursor<Customer> query(String name, String surname);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
### @Param
|
||||
|
||||
With the `@Param` annotation, the argument will be placed in the query at the place corresponding to the value passed to the `@Param` annotation.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends ArangoRepository<Customer, String>{
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @name AND c.surname == @surname RETURN c")
|
||||
ArangoCursor<Customer> query(@Param("name") String name, @Param("surname") String surname);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
### @BindVars
|
||||
|
||||
In addition you can use a method parameter of type `Map<String, Object>` annotated with `@BindVars` as your bind parameters. You can then fill the map with any parameter used in the query. (see [here](https://docs.arangodb.com/3.1/AQL/Fundamentals/BindParameters.html#bind-parameters) for more Information about Bind Parameters).
|
||||
|
||||
```java
|
||||
public interface MyRepository extends ArangoRepository<Customer, String>{
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @name AND c.surname = @surname RETURN c")
|
||||
ArangoCursor<Customer> query(@BindVars Map<String, Object> bindVars);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
A mixture of any of these methods can be used. Parameters with the same name from an `@Param` annotation will override those in the `bindVars`.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends ArangoRepository<Customer, String>{
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @name AND c.surname = @surname RETURN c")
|
||||
ArangoCursor<Customer> query(@BindVars Map<String, Object> bindVars, @Param("name") String name);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Query options
|
||||
|
||||
`AqlQueryOptions` can also be passed to the driver, as an argument anywhere in the method signature.
|
||||
|
||||
```java
|
||||
public interface MyRepository extends ArangoRepository<Customer, String>{
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @name AND c.surname == @surname RETURN c")
|
||||
ArangoCursor<Customer> query(@Param("name") String name, @Param("surname") String surname, AqlQueryOptions options);
|
||||
|
||||
}
|
||||
```
|
|
@ -0,0 +1,109 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Queries
|
||||
|
||||
Spring Data ArangoDB supports three kinds of queries:
|
||||
|
||||
- [Derived queries](DerivedQueries.md)
|
||||
- [Query methods](QueryMethods.md)
|
||||
- [Named queries](NamedQueries.md)
|
||||
|
||||
## Return types
|
||||
|
||||
The method return type for single results can be a primitive type, a domain class, `Map<String, Object>`, `BaseDocument`, `BaseEdgeDocument`, `Optional<Type>`, `GeoResult<Type>`.
|
||||
|
||||
The method return type for multiple results can additionally be `ArangoCursor<Type>`, `Iterable<Type>`, `Collection<Type>`, `List<Type>`, `Set<Type>`, `Page<Type>`, `Slice<Type>`, `GeoPage<Type>`, `GeoResults<Type>` where Type can be everything a single result can be.
|
||||
|
||||
## AQL query options
|
||||
|
||||
You can set additional options for the query and the created cursor over the class `AqlQueryOptions` which you can simply define as a method parameter without a specific name. AqlQuery options can also be defined with the `@QueryOptions` annotation, as shown below. Aql query options from an annotation and those from an argument are merged if both exist, with those in the argument taking precedence.
|
||||
|
||||
The `AqlQueryOptions` allows you to set the cursor time-to-live, batch-size,
|
||||
caching flag and several other settings. This special parameter works with both
|
||||
[query methods](QueryMethods.md)
|
||||
and [derived queries](DerivedQueries.md). Keep in mind that some options, like
|
||||
time-to-live, are only effective if the method return type is`ArangoCursor<T>`
|
||||
or `Iterable<T>`.
|
||||
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
public interface MyRepository extends Repository<Customer, String> {
|
||||
|
||||
|
||||
@Query("FOR c IN customers FILTER c.name == @0 RETURN c")
|
||||
Iterable<Customer> query(String name, AqlQueryOptions options);
|
||||
|
||||
|
||||
Iterable<Customer> findByName(String name, AqlQueryOptions options);
|
||||
|
||||
|
||||
@QueryOptions(maxPlans = 1000, ttl = 128)
|
||||
ArangoCursor<Customer> findByAddressZipCode(ZipCode zipCode);
|
||||
|
||||
|
||||
@Query("FOR c IN customers FILTER c[@field] == @value RETURN c")
|
||||
@QueryOptions(cache = true, ttl = 128)
|
||||
ArangoCursor<Customer> query(Map<String, Object> bindVars, AqlQueryOptions options);
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Paging and sorting
|
||||
|
||||
Spring Data ArangoDB supports Spring Data's `Pageable` and `Sort` parameters for repository query methods. If these parameters are used together with a native query, either through `@Query` annotation or [named queries](NamedQueries.md), a placeholder must be specified:
|
||||
|
||||
- `#pageable` for `Pageable` parameter
|
||||
- `#sort` for `Sort` parameter
|
||||
|
||||
Sort properties or paths are attributes separated by dots (e.g. `customer.age`). Some rules apply for them:
|
||||
|
||||
- they must not begin or end with a dot (e.g. `.customer.age`)
|
||||
- dots in attributes are supported, but the whole attribute must be enclosed by backticks (e.g. `` customer.`attr.with.dots` ``
|
||||
- backticks in attributes are supported, but they must be escaped with a backslash (e.g. `` customer.attr_with\` ``)
|
||||
- any backslashes (that do not escape a backtick) are escaped (e.g. `customer\` => `customer\\`)
|
||||
|
||||
**Examples**
|
||||
|
||||
```
|
||||
just.`some`.`attributes.that`.`form\``.a path\`.\ is converted to
|
||||
`just`.`some`.`attributes.that`.`form\``.`a path\``.`\\`
|
||||
```
|
||||
|
||||
**Native queries example**
|
||||
|
||||
```java
|
||||
public interface CustomerRepository extends ArangoRepository<Customer> {
|
||||
|
||||
@Query("FOR c IN customer FILTER c.name == @1 #pageable RETURN c")
|
||||
Page<Customer> findByNameNative(Pageable pageable, String name);
|
||||
|
||||
@Query("FOR c IN customer FILTER c.name == @1 #sort RETURN c")
|
||||
List<Customer> findByNameNative(Sort sort, String name);
|
||||
}
|
||||
|
||||
// don't forget to specify the var name of the document
|
||||
final Pageable page = PageRequest.of(1, 10, Sort.by("c.age"));
|
||||
repository.findByNameNative(page, "Matt");
|
||||
|
||||
final Sort sort = Sort.by(Direction.DESC, "c.age");
|
||||
repository.findByNameNative(sort, "Tony");
|
||||
```
|
||||
|
||||
**Derived queries example**
|
||||
|
||||
```java
|
||||
public interface CustomerRepository extends ArangoRepository<Customer> {
|
||||
|
||||
Page<Customer> findByName(Pageable pageable, String name);
|
||||
|
||||
List<Customer> findByName(Sort sort, String name);
|
||||
}
|
||||
|
||||
// no var name is necessary for derived queries
|
||||
final Pageable page = PageRequest.of(1, 10, Sort.by("age"));
|
||||
repository.findByName(page, "Matt");
|
||||
|
||||
final Sort sort = Sort.by(Direction.DESC, "age");
|
||||
repository.findByName(sort, "Tony");
|
||||
```
|
|
@ -0,0 +1,98 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Query by example
|
||||
|
||||
## ArangoRepository.exists
|
||||
|
||||
```
|
||||
ArangoRepository.exists(Example<S> example) : boolean
|
||||
```
|
||||
|
||||
Checks whether the data store contains elements that match the given `Example`.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **example**: `Example<S>`
|
||||
|
||||
The example to use. Must not be `null`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
MyDomainClass sample = new MyDomainClass();
|
||||
sample.setName("John"); // set some data in sample
|
||||
boolean exists = repository.exists(Example.of(sample));
|
||||
```
|
||||
|
||||
## ArangoRepository.findOne
|
||||
|
||||
```
|
||||
ArangoRepository.findOne(Example<S> example) : Optional<S>
|
||||
```
|
||||
|
||||
Returns a single entity matching the given `Example` or `Optional#empty()` if none was found.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **example**: `Example<S>`
|
||||
|
||||
The example to use. Must not be `null`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
MyDomainClass sample = new MyDomainClass();
|
||||
sample.setName("John"); // set some data in sample
|
||||
MyDomainClass entity = repository.findOne(Example.of(sample));
|
||||
```
|
||||
|
||||
## ArangoRepository.findAll
|
||||
|
||||
```
|
||||
ArangoRepository.findAll(Example<S> example) : Iterable<S>
|
||||
```
|
||||
|
||||
Returns all entities matching the given `Example`. In case no match could be found an empty `Iterable` is returned.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **example**: `Example<S>`
|
||||
|
||||
The example to use. Must not be `null`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
MyDomainClass sample = new MyDomainClass();
|
||||
sample.setName("John"); // set some data in sample
|
||||
Iterable<MyDomainClass> entities = repository.findAll(Example.of(sample));
|
||||
```
|
||||
|
||||
## ArangoRepository.count
|
||||
|
||||
```
|
||||
ArangoRepository.count(Example<S> example) : long
|
||||
```
|
||||
|
||||
Returns the number of instances matching the given `Example`.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **example**: `Example<S>`
|
||||
|
||||
The example to use. Must not be `null`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Autowired MyRepository repository;
|
||||
|
||||
MyDomainClass sample = new MyDomainClass();
|
||||
sample.setName("John"); // set some data in sample
|
||||
long count = repository.count(Example.of(sample));
|
||||
```
|
|
@ -0,0 +1,34 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Repositories
|
||||
|
||||
Spring Data Commons provides a composable repository infrastructure which Spring Data ArangoDB is built on. These allow for interface-based composition of repositories consisting of provided default implementations for certain interfaces (like `CrudRepository`) and custom implementations for other methods.
|
||||
|
||||
The base interface of Spring Data ArangoDB is `ArangoRepository`. It extends the Spring Data interfaces `PagingAndSortingRepository` and `QueryByExampleExecutor`. To get access to all Sping Data ArangoDB repository functionallity simply create your own interface extending `ArangoRepository<T, ID>`.
|
||||
|
||||
The type `T` represents your domain class and type `ID` the type of your field annotated with `@Id` in your domain class. This field is persistend in ArangoDB as document field `_key`.
|
||||
|
||||
**Examples**
|
||||
|
||||
```java
|
||||
@Document
|
||||
public class MyDomainClass {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
}
|
||||
|
||||
public interface MyRepository extends ArangoRepository<MyDomainClass, String> {
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Instances of a Repository are created in Spring beans through the auto-wired mechanism of Spring.
|
||||
|
||||
```java
|
||||
public class MySpringBean {
|
||||
|
||||
@Autowired
|
||||
private MyRepository rep;
|
||||
|
||||
}
|
||||
```
|
|
@ -0,0 +1,314 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Manipulating the collection
|
||||
|
||||
## ArangoOperations.collection
|
||||
|
||||
```
|
||||
ArangoOperations.collection(Class<?> entityClass) : CollectionOperations
|
||||
```
|
||||
|
||||
```
|
||||
ArangoOperations.collection(String name) : CollectionOperations
|
||||
```
|
||||
|
||||
Returns the operations interface for a collection. If the collection does not exists, it is created automatically.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **entityClass**: `Class<?>`
|
||||
|
||||
The entity type representing the collection
|
||||
|
||||
- **name**: `String`
|
||||
|
||||
The name of the collection
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
|
||||
// -- or --
|
||||
|
||||
CollectionOperations collection = template.collection("some-collection-name");
|
||||
```
|
||||
|
||||
## CollectionOperations.truncate
|
||||
|
||||
```
|
||||
CollectionOperations.truncate() : void
|
||||
```
|
||||
|
||||
Removes all documents from the collection, but leaves the indexes intact
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
collection.truncate();
|
||||
```
|
||||
|
||||
## CollectionOperations.drop
|
||||
|
||||
```
|
||||
CollectionOperations.drop() : void
|
||||
```
|
||||
|
||||
Deletes the collection from the database.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
collection.drop();
|
||||
```
|
||||
|
||||
## CollectionOperations.count
|
||||
|
||||
```
|
||||
CollectionOperation.count() : long
|
||||
```
|
||||
|
||||
Counts the documents in a collection
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
long count = collection.count();
|
||||
```
|
||||
|
||||
## CollectionOperations.getProperties
|
||||
|
||||
```
|
||||
CollectionOperations.getProperties() : CollectionPropertiesEntity
|
||||
```
|
||||
|
||||
Reads the properties of the specified collection
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
CollectionPropertiesEntity properties = collection.getProperties();
|
||||
```
|
||||
|
||||
## CollectionOperation.getIndexes
|
||||
|
||||
```
|
||||
CollectionOperations.getIndexes() : Collection<IndexEntity>
|
||||
```
|
||||
|
||||
Returns all indexes of the collection
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
Collection<IndexEntity> indexes = collection.getIndexes();
|
||||
```
|
||||
|
||||
## CollectionOperations.ensureHashIndex
|
||||
|
||||
```
|
||||
CollectionOperations.ensureHashIndex(Iterable<String> fields, HashIndexOptions options) : IndexEntity
|
||||
```
|
||||
|
||||
Creates a hash index for the collection if it does not already exist.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **fields**: `Iterable<String>`
|
||||
|
||||
A list of attribute paths
|
||||
|
||||
- **options**: `HashIndexOptions`
|
||||
|
||||
- **unique**: `Boolean`
|
||||
|
||||
If true, then create a unique index
|
||||
|
||||
- **sparse**: `Boolean`
|
||||
|
||||
If true, then create a sparse index
|
||||
|
||||
- **deduplicate**: `Boolean`
|
||||
|
||||
If false, the deduplication of array values is turned off.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
IndexEntity index = collection.ensureHashIndex(Arrays.asList("a", "b.c"), new HashIndexOptions());
|
||||
// the index has been created with the handle `index.getId()`
|
||||
```
|
||||
|
||||
## CollectionOperations.ensureSkiplistIndex
|
||||
|
||||
```
|
||||
CollectionOperations.ensureSkiplistIndex(Iterable<String> fields, SkiplistIndexOptions options) : IndexEntity
|
||||
```
|
||||
|
||||
Creates a skip-list index for the collection if it does not already exist.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **fields**: `Iterable<String>`
|
||||
|
||||
A list of attribute paths
|
||||
|
||||
- **options**: `SkiplistIndexOptions`
|
||||
|
||||
- **unique**: `Boolean`
|
||||
|
||||
If true, then create a unique index
|
||||
|
||||
- **sparse**: `Boolean`
|
||||
|
||||
If true, then create a sparse index
|
||||
|
||||
- **deduplicate**: `Boolean`
|
||||
|
||||
If false, the deduplication of array values is turned off.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
IndexEntity index = collection.ensureSkiplistIndex(Arrays.asList("a", "b.c"), new SkiplistIndexOptions());
|
||||
// the index has been created with the handle `index.getId()`
|
||||
```
|
||||
|
||||
## CollectionOperations.ensureGeoIndex
|
||||
|
||||
```
|
||||
CollectionOperations.ensureGeoIndex(Iterable<String> fields, GeoIndexOptions options) : IndexEntity
|
||||
```
|
||||
|
||||
Creates a geo index for the collection if it does not already exist.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **fields**: `Iterable<String>`
|
||||
|
||||
A list of attribute paths
|
||||
|
||||
- **options**: `GeoIndexOptions`
|
||||
|
||||
- **geoJson**: `Boolean`
|
||||
|
||||
If a geo-spatial index on a location is constructed and geoJson is true, then the order within the array is longitude followed by latitude. This corresponds to the format described in.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
IndexEntity index = collection.ensureGeoIndex(Arrays.asList("latitude", "longitude"), new GeoIndexOptions());
|
||||
// the index has been created with the handle `index.getId()`
|
||||
```
|
||||
|
||||
## CollectionOperations.ensureFulltextIndex
|
||||
|
||||
```
|
||||
CollectionOperations.ensureFulltextIndex(Iterable<String> fields, FulltextIndexOptions options) : IndexEntity
|
||||
```
|
||||
|
||||
Creates a fulltext index for the collection if it does not already exist.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **fields**: `Iterable<String>`
|
||||
|
||||
A list of attribute paths
|
||||
|
||||
- **options**: `FulltextIndexOptions`
|
||||
|
||||
- **minLength**: `Integer`
|
||||
|
||||
Minimum character length of words to index. Will default to a server-defined value if unspecified. It is thus recommended to set this value explicitly when creating the index.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
IndexEntity index = collection.ensureFulltextIndex(Arrays.asList("description"), new FulltextIndexOptions());
|
||||
// the index has been created with the handle `index.getId()`
|
||||
```
|
||||
|
||||
## CollectionOperations.ensurePersistentIndex
|
||||
|
||||
```
|
||||
CollectionOperations.ensurePersistentIndex(Iterable<String> fields, PersistentIndexOptions options) : IndexEntity
|
||||
```
|
||||
|
||||
Creates a persistent index for the collection if it does not already exist.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **fields**: `Iterable<String>`
|
||||
|
||||
A list of attribute paths
|
||||
|
||||
- **options**: `PersistentIndexOptions`
|
||||
|
||||
- **unique**: `Boolean`
|
||||
|
||||
If true, then create a unique index
|
||||
|
||||
- **sparse**: `Boolean`
|
||||
|
||||
If true, then create a sparse index
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
IndexEntity index = collection.ensurePersistentIndex(Arrays.asList("a", "b.c"), new PersistentIndexOptions());
|
||||
// the index has been created with the handle `index.getId()`
|
||||
```
|
||||
|
||||
## CollectionOperations.dropIndex
|
||||
|
||||
```
|
||||
CollectionOperations.dropIndex(String id) : void
|
||||
```
|
||||
|
||||
Deletes the index with the given _id_ from the collection.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **id**: `String`
|
||||
|
||||
The index-handle
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
CollectionOperations collection = template.collection(MyObject.class);
|
||||
collection.dropIndex("some-index");
|
||||
```
|
|
@ -0,0 +1,286 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Manipulating documents
|
||||
|
||||
## ArangoOperations.exists
|
||||
|
||||
```
|
||||
ArangoOperations.exists(String id, Class<?> entityClass) : boolean
|
||||
```
|
||||
|
||||
Checks whether the document exists by reading a single document head
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **id**: `String`
|
||||
|
||||
The id or key of the document
|
||||
|
||||
- **entityClass**: `Class<T>`
|
||||
|
||||
The entity class which represents the collection
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
boolean exists = template.exists("some-id", MyObject.class);
|
||||
```
|
||||
|
||||
## ArangoOperations.find
|
||||
|
||||
```
|
||||
ArangoOperations.find(String id, Class<T> entityClass, DocumentReadOptions options) : Optional<T>
|
||||
```
|
||||
|
||||
Retrieves the document with the given _id_ from a collection.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **id**: `String`
|
||||
|
||||
The id or key of the document
|
||||
|
||||
- **entityClass**: `Class<T>`
|
||||
|
||||
The entity class which represents the collection
|
||||
|
||||
- **options**: `DocumentReadOptions`
|
||||
|
||||
- **ifNoneMatch**: `String`
|
||||
|
||||
Document revision must not contain If-None-Match
|
||||
|
||||
- **ifMatch**: `String`
|
||||
|
||||
Document revision must contain If-Match
|
||||
|
||||
- **catchException**: `Boolean`
|
||||
|
||||
Whether or not catch possible thrown exceptions
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
Optional<MyObject> doc = template.find("some-id", MyObject.class, new DocumentReadOptions());
|
||||
```
|
||||
|
||||
## ArangoOperations.repsert
|
||||
|
||||
```
|
||||
ArangoOperations.repsert(T value) : void
|
||||
```
|
||||
|
||||
Creates a new document from the given document, unless there is already a document with the id given. In that case it replaces the document.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **value**: `T`
|
||||
|
||||
A representation of a single document
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
MyObject myObj = ...
|
||||
template.repsert(myObj);
|
||||
```
|
||||
|
||||
## ArangoOperations.insert
|
||||
|
||||
```
|
||||
ArangoOperations.insert(T value, DocumentCreateOptions options) : DocumentEntity
|
||||
```
|
||||
|
||||
Creates a new document from the given document, unless there is already a document with the \_key given. If no \_key is given, a new unique \_key is generated automatically.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **value**: `T`
|
||||
|
||||
A representation of a single document
|
||||
|
||||
- **options**: `DocumentCreateOptions`
|
||||
|
||||
- **waitForSync**: `Boolean`
|
||||
|
||||
Wait until document has been synced to disk.
|
||||
|
||||
- **returnNew**: `Boolean`
|
||||
|
||||
Return additionally the complete new document under the attribute new in the result.
|
||||
|
||||
- **returnOld**: `Boolean`
|
||||
|
||||
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
|
||||
|
||||
- **overwrite**: `Boolean`
|
||||
|
||||
If set to true, the insert becomes a replace-insert. If a document with the same \_key already exists the new document is not rejected with unique constraint violated but will replace the old document.
|
||||
|
||||
- **silent**: `Boolean`
|
||||
|
||||
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
MyObject myObj = ...
|
||||
DocumentEntity info = template.insert(myObj, new DocumentCreateOptions());
|
||||
```
|
||||
|
||||
## ArangoOperations.replace
|
||||
|
||||
```
|
||||
ArangoOperations.replace(String id, T value, DocumentReplaceOptions options) : DocumentEntity
|
||||
```
|
||||
|
||||
Replaces the document with _id_ with the one in the body, provided there is such a document and no precondition is violated.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **id**: `String`
|
||||
|
||||
The id or key of the document
|
||||
|
||||
- **value**: `T`
|
||||
|
||||
A representation of a single document
|
||||
|
||||
- **options**: `DocumentReplaceOptions`
|
||||
|
||||
- **waitForSync**: `Boolean`
|
||||
|
||||
Wait until document has been synced to disk.
|
||||
|
||||
- **ignoreRevs**: `Boolean`
|
||||
|
||||
By default, or if this is set to true, the \_rev attributes in the given document is ignored. If this is set to false, then the \_rev attribute given in the body document is taken as a precondition. The document is only replaced if the current revision is the one specified.
|
||||
|
||||
- **ifMatch**: `String`
|
||||
|
||||
Replace a document based on target revision
|
||||
|
||||
- **returnNew**: `Boolean`
|
||||
|
||||
Return additionally the complete new document under the attribute new in the result.
|
||||
|
||||
- **returnOld**: `Boolean`
|
||||
|
||||
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
|
||||
|
||||
- **silent**: `Boolean`
|
||||
|
||||
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
MyObject myObj = ...
|
||||
DocumentEntity info = template.replace("some-id", myObj, new DocumentReplaceOptions());
|
||||
```
|
||||
|
||||
## ArangoOperations.update
|
||||
|
||||
```
|
||||
ArangoOperations.update(String id, T value, DocumentUpdateOptions options) : DocumentEntity
|
||||
```
|
||||
|
||||
Partially updates the document identified by document id or key. The value must contain a document with the attributes to patch (the patch document). All attributes from the patch document will be added to the existing document if they do not yet exist, and overwritten in the existing document if they do exist there.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **id**: `String`
|
||||
|
||||
The id or key of the document
|
||||
|
||||
- **value**: `T`
|
||||
|
||||
A representation of a single document
|
||||
|
||||
- **options**: `DocumentUpdateOptions`
|
||||
|
||||
- **waitForSync**: `Boolean`
|
||||
|
||||
Wait until document has been synced to disk.
|
||||
|
||||
- **ignoreRevs**: `Boolean`
|
||||
|
||||
By default, or if this is set to true, the \_rev attributes in the given document is ignored. If this is set to false, then the \_rev attribute given in the body document is taken as a precondition. The document is only replaced if the current revision is the one specified.
|
||||
|
||||
- **ifMatch**: `String`
|
||||
|
||||
Replace a document based on target revision
|
||||
|
||||
- **returnNew**: `Boolean`
|
||||
|
||||
Return additionally the complete new document under the attribute new in the result.
|
||||
|
||||
- **returnOld**: `Boolean`
|
||||
|
||||
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
|
||||
|
||||
- **silent**: `Boolean`
|
||||
|
||||
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
MyObject myObj = ...
|
||||
DocumentEntity info = template.update("some-id", myObj, new DocumentReplaceOptions());
|
||||
```
|
||||
|
||||
## ArangoOperations.delete
|
||||
|
||||
```
|
||||
ArangoOperations.delete(String id, Class<?> entityClass, DocumentDeleteOptions options) : DocumentEntity
|
||||
```
|
||||
|
||||
Deletes the document with the given _id_ from a collection.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **id**: `String`
|
||||
|
||||
The id or key of the document
|
||||
|
||||
- **entityClass**: `Class<T>`
|
||||
|
||||
The entity class which represents the collection
|
||||
|
||||
- **options**: `DocumentDeleteOptions`
|
||||
|
||||
- **waitForSync**: `Boolean`
|
||||
|
||||
Wait until document has been synced to disk.
|
||||
|
||||
- **ifMatch**: `String`
|
||||
|
||||
Replace a document based on target revision
|
||||
|
||||
- **returnOld**: `Boolean`
|
||||
|
||||
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
|
||||
|
||||
- **silent**: `Boolean`
|
||||
|
||||
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
template.delete("some-id", MyObject.class, new DocumentDeleteOptions());
|
||||
```
|
|
@ -0,0 +1,255 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Manipulating multiple documents
|
||||
|
||||
## ArangoOperations.find
|
||||
|
||||
```
|
||||
ArangoOperations.find(Iterable<String> ids, Class<T> entityClass) : Iterable<T>
|
||||
```
|
||||
|
||||
Retrieves multiple documents with the given _ids_ from a collection.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **ids**: `Iterable<String>`
|
||||
|
||||
The ids or keys of the documents
|
||||
|
||||
- **entityClass**: `Class<T>`
|
||||
|
||||
The entity type of the documents
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
Iterable<MyObject> docs = template.find(Arrays.asList("some-id", "some-other-id"), MyObject.class);
|
||||
```
|
||||
|
||||
## ArangoOperations.findAll
|
||||
|
||||
```
|
||||
ArangoOperations.findAll(Class<T> entityClass) : Iterable<T>
|
||||
```
|
||||
|
||||
Retrieves all documents from a collection.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **entityClass**: `Class<T>`
|
||||
|
||||
The entity class which represents the collection
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
Iterable<MyObject> docs = template.find(MyObject.class);
|
||||
```
|
||||
|
||||
## ArangoOperations.insert
|
||||
|
||||
```
|
||||
ArangoOperations.insert(Iterable<T> values, Class<T> entityClass, DocumentCreateOptions options) : MultiDocumentEntity
|
||||
```
|
||||
|
||||
Creates new documents from the given documents, unless there is already a document with the \_key given. If no \_key is given, a new unique \_key is generated automatically.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **values**: `Iterable<T>`
|
||||
|
||||
A List of documents
|
||||
|
||||
- **entityClass**: `Class<T>`
|
||||
|
||||
The entity class which represents the collection
|
||||
|
||||
- **options**: `DocumentCreateOptions`
|
||||
|
||||
- **waitForSync**: `Boolean`
|
||||
|
||||
Wait until document has been synced to disk.
|
||||
|
||||
- **returnNew**: `Boolean`
|
||||
|
||||
Return additionally the complete new document under the attribute new in the result.
|
||||
|
||||
- **returnOld**: `Boolean`
|
||||
|
||||
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
|
||||
|
||||
- **overwrite**: `Boolean`
|
||||
|
||||
If set to true, the insert becomes a replace-insert. If a document with the same \_key already exists the new document is not rejected with unique constraint violated but will replace the old document.
|
||||
|
||||
- **silent**: `Boolean`
|
||||
|
||||
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
MyObject obj1 = ...
|
||||
MyObject obj2 = ...
|
||||
MyObject obj3 = ...
|
||||
template.insert(Arrays.asList(obj1, obj2, obj3));
|
||||
```
|
||||
|
||||
## ArangoOperations.replace
|
||||
|
||||
```
|
||||
ArangoOperations.replace(Iterable<T> values, Class<T> entityClass, DocumentReplaceOptions options) : MultiDocumentEntity
|
||||
```
|
||||
|
||||
Replaces multiple documents in the specified collection with the ones in the values, the replaced documents are specified by the \_key attributes in the documents in values.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **values**: `Iterable<T>`
|
||||
|
||||
A List of documents
|
||||
|
||||
- **entityClass**: `Class<T>`
|
||||
|
||||
The entity class which represents the collection
|
||||
|
||||
- **options**: `DocumentReplaceOptions`
|
||||
|
||||
- **waitForSync**: `Boolean`
|
||||
|
||||
Wait until document has been synced to disk.
|
||||
|
||||
- **ignoreRevs**: `Boolean`
|
||||
|
||||
By default, or if this is set to true, the \_rev attributes in the given document is ignored. If this is set to false, then the \_rev attribute given in the body document is taken as a precondition. The document is only replaced if the current revision is the one specified.
|
||||
|
||||
- **ifMatch**: `String`
|
||||
|
||||
Replace a document based on target revision
|
||||
|
||||
- **returnNew**: `Boolean`
|
||||
|
||||
Return additionally the complete new document under the attribute new in the result.
|
||||
|
||||
- **returnOld**: `Boolean`
|
||||
|
||||
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
|
||||
|
||||
- **silent**: `Boolean`
|
||||
|
||||
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
MyObject obj1 = ...
|
||||
MyObject obj2 = ...
|
||||
MyObject obj3 = ...
|
||||
template.replace(Arrays.asList(obj1, obj2, obj3), new DocumentReplaceOptions());
|
||||
```
|
||||
|
||||
## ArangoOperations.update
|
||||
|
||||
```
|
||||
ArangoOperations.update(Iterable<T> values, Class<T> entityClass, DocumentUpdateOptions options) : MultiDocumentEntity
|
||||
```
|
||||
|
||||
Partially updates documents, the documents to update are specified by the \_key attributes in the objects on values. Vales must contain a list of document updates with the attributes to patch (the patch documents). All attributes from the patch documents will be added to the existing documents if they do not yet exist, and overwritten in the existing documents if they do exist there.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **values**: `Iterable<T>`
|
||||
|
||||
A List of documents
|
||||
|
||||
- **entityClass**: `Class<T>`
|
||||
|
||||
The entity class which represents the collection
|
||||
|
||||
- **options**: `DocumentUpdateOptions`
|
||||
|
||||
- **waitForSync**: `Boolean`
|
||||
|
||||
Wait until document has been synced to disk.
|
||||
|
||||
- **ignoreRevs**: `Boolean`
|
||||
|
||||
By default, or if this is set to true, the \_rev attributes in the given document is ignored. If this is set to false, then the \_rev attribute given in the body document is taken as a precondition. The document is only replaced if the current revision is the one specified.
|
||||
|
||||
- **ifMatch**: `String`
|
||||
|
||||
Replace a document based on target revision
|
||||
|
||||
- **returnNew**: `Boolean`
|
||||
|
||||
Return additionally the complete new document under the attribute new in the result.
|
||||
|
||||
- **returnOld**: `Boolean`
|
||||
|
||||
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
|
||||
|
||||
- **silent**: `Boolean`
|
||||
|
||||
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
MyObject obj1 = ...
|
||||
MyObject obj2 = ...
|
||||
MyObject obj3 = ...
|
||||
template.update(Arrays.asList(obj1, obj2, obj3), new DocumentUpdateOptions());
|
||||
```
|
||||
|
||||
## ArangoOperations.delete
|
||||
|
||||
```
|
||||
ArangoOperations.delete(Iterable<Object> values, Class<?> entityClass, DocumentDeleteOptions options) : MultiDocumentEntity
|
||||
```
|
||||
|
||||
Deletes multiple documents from a collection.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **values**: `Iterable<Object>`
|
||||
|
||||
The keys of the documents or the documents themselves
|
||||
|
||||
- **entityClass**: `Class<?>`
|
||||
|
||||
The entity class which represents the collection
|
||||
|
||||
- **options**: `DocumentDeleteOptions`
|
||||
|
||||
- **waitForSync**: `Boolean`
|
||||
|
||||
Wait until document has been synced to disk.
|
||||
|
||||
- **ifMatch**: `String`
|
||||
|
||||
Replace a document based on target revision
|
||||
|
||||
- **returnOld**: `Boolean`
|
||||
|
||||
Additionally return the complete old document under the attribute old in the result. Only available if the _overwrite_ option is used.
|
||||
|
||||
- **silent**: `Boolean`
|
||||
|
||||
If set to true, an empty object will be returned as response. No meta-data will be returned for the created document. This option can be used to save some network traffic.
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
collection.delete(Arrays.asList("some-id", "some-other-id"), MyObject.class, new DocumentDeleteOptions());
|
||||
```
|
|
@ -0,0 +1,103 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
## ArangoOperations.query
|
||||
|
||||
```
|
||||
ArangoOperations.query(String query, Map<String, Object> bindVars, AqlQueryOptions options, Class<T> entityClass) : ArangoCursor<T>
|
||||
```
|
||||
|
||||
Performs a database query using the given _query_ and _bindVars_, then returns a new _ArangoCursor_ instance for the result list.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- **query**: `String`
|
||||
|
||||
An AQL query string
|
||||
|
||||
- **bindVars**: `Map<String, Object>`
|
||||
|
||||
key/value pairs defining the variables to bind the query to
|
||||
|
||||
- **options**: `AqlQueryOptions`
|
||||
|
||||
- **count**: `Boolean`
|
||||
|
||||
Indicates whether the number of documents in the result set should be returned in the "count" attribute of the result. Calculating the "count" attribute might have a performance impact for some queries in the future so this option is turned off by default, and "count" is only returned when requested.
|
||||
|
||||
- **ttl**: `Integer`
|
||||
|
||||
The time-to-live for the cursor (in seconds). The cursor will be removed on the server automatically after the specified amount of time. This is useful to ensure garbage collection of cursors that are not fully fetched by clients. If not set, a server-defined value will be used.
|
||||
|
||||
- **batchSize**: `Integer`
|
||||
|
||||
Maximum number of result documents to be transferred from the server to the client in one roundtrip. If this attribute is not set, a server-controlled default value will be used. A batchSize value of 0 is disallowed.
|
||||
|
||||
- **memoryLimit**: `Long`
|
||||
|
||||
The maximum number of memory (measured in bytes) that the query is allowed to use. If set, then the query will fail with error "resource limit exceeded" in case it allocates too much memory. A value of 0 indicates that there is no memory limit.
|
||||
|
||||
- **cache**: `Boolean`
|
||||
|
||||
Flag to determine whether the AQL query cache shall be used. If set to false, then any query cache lookup will be skipped for the query. If set to true, it will lead to the query cache being checked for the query if the query cache mode is either on or demand.
|
||||
|
||||
- **failOnWarning**: `Boolean`
|
||||
|
||||
When set to true, the query will throw an exception and abort instead of producing a warning. This option should be used during development to catch potential issues early. When the attribute is set to false, warnings will not be propagated to exceptions and will be returned with the query result. There is also a server configuration option --query.fail-on-warning for setting the default value for failOnWarning so it does not need to be set on a per-query level.
|
||||
|
||||
- **profile**: `Boolean`
|
||||
|
||||
If set to true, then the additional query profiling information will be returned in the sub-attribute profile of the extra return attribute if the query result is not served from the query cache.
|
||||
|
||||
- **maxTransactionSize**: `Long`
|
||||
|
||||
Transaction size limit in bytes. Honored by the RocksDB storage engine only.
|
||||
|
||||
- **maxWarningCount**: `Long`
|
||||
|
||||
Limits the maximum number of warnings a query will return. The number of warnings a query will return is limited to 10 by default, but that number can be increased or decreased by setting this attribute.
|
||||
|
||||
- **intermediateCommitCount**: `Long`
|
||||
|
||||
Maximum number of operations after which an intermediate commit is performed automatically. Honored by the RocksDB storage engine only.
|
||||
|
||||
- **intermediateCommitSize**: `Long`
|
||||
|
||||
Maximum total size of operations after which an intermediate commit is performed automatically. Honored by the RocksDB storage engine only.
|
||||
|
||||
- **satelliteSyncWait**: `Double`
|
||||
|
||||
This enterprise parameter allows to configure how long a DBServer will have time to bring the satellite collections involved in the query into sync. The default value is 60.0 (seconds). When the max time has been reached the query will be stopped.
|
||||
|
||||
- **skipInaccessibleCollections**
|
||||
|
||||
AQL queries (especially graph traversals) will treat collection to which a user has no access rights as if these collections were empty. Instead of returning a forbidden access error, your queries will execute normally. This is intended to help with certain use-cases: A graph contains several collections and different users execute AQL queries on that graph. You can now naturally limit the accessible results by changing the access rights of users on collections. This feature is only available in the Enterprise Edition.
|
||||
|
||||
- **fullCount**: `Boolean`
|
||||
|
||||
If set to true and the query contains a LIMIT clause, then the result will have an extra attribute with the sub-attributes stats and fullCount, { ... , "extra": { "stats": { "fullCount": 123 } } }. The fullCount attribute will contain the number of documents in the result before the last LIMIT in the query was applied. It can be used to count the number of documents that match certain filter criteria, but only return a subset of them, in one go. It is thus similar to MySQL's SQL_CALC_FOUND_ROWS hint. Note that setting the option will disable a few LIMIT optimizations and may lead to more documents being processed, and thus make queries run longer. Note that the fullCount attribute will only be present in the result if the query has a LIMIT clause and the LIMIT clause is actually used in the query.
|
||||
|
||||
- **maxPlans**: `Integer`
|
||||
|
||||
Limits the maximum number of plans that are created by the AQL query optimizer.
|
||||
|
||||
- **rules**: `Collection<String>`
|
||||
|
||||
A list of to-be-included or to-be-excluded optimizer rules can be put into this attribute, telling the optimizer to include or exclude specific rules. To disable a rule, prefix its name with a -, to enable a rule, prefix it with a +. There is also a pseudo-rule all, which will match all optimizer rules.
|
||||
|
||||
- **stream**: `Boolean`
|
||||
|
||||
Specify true and the query will be executed in a streaming fashion. The query result is not stored on the server, but calculated on the fly. Beware: long-running queries will need to hold the collection locks for as long as the query cursor exists. When set to false a query will be executed right away in its entirety. In that case query results are either returned right away (if the resultset is small enough), or stored on the arangod instance and accessible via the cursor API (with respect to the ttl). It is advisable to only use this option on short-running queries or without exclusive locks (write-locks on MMFiles). Please note that the query options cache, count and fullCount will not work on streaming queries. Additionally query statistics, warnings and profiling data will only be available after the query is finished. The default value is false.
|
||||
|
||||
- **type**: `Class<T>`
|
||||
|
||||
The type of the result (POJO class, `VPackSlice` or `Collection`/`List`/`Map`)
|
||||
|
||||
**Examples**
|
||||
|
||||
```Java
|
||||
@Autowired ArangoOperations template;
|
||||
|
||||
ArangoCursor<MyObject> cursor = template.query("FOR i IN @@collection RETURN i"
|
||||
new MapBuilder().put("@collection", MyObject.class).get(),
|
||||
new AqlQueryOptions(),
|
||||
MyObject.class);
|
||||
```
|
|
@ -0,0 +1,5 @@
|
|||
<!-- don't edit here, its from https://@github.com/arangodb/spring-data.git / docs/Drivers/ -->
|
||||
# Template
|
||||
|
||||
With `ArangoTemplate` Spring Data ArangoDB offers a central support for interactions with the database over a rich feature set. It mostly offers the features from the ArangoDB Java driver with additional exception translation from the drivers exceptions to the Spring Data access exceptions inheriting the `DataAccessException` class.
|
||||
The `ArangoTemplate` class is the default implementation of the operations interface `ArangoOperations` which developers of Spring Data are encouraged to code against.
|
|
@ -120,50 +120,23 @@ ClusterIndexFactory::ClusterIndexFactory() {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
// both engines support all types right now
|
||||
static const std::vector<std::string> supported_norm = {
|
||||
"edge",
|
||||
"fulltext",
|
||||
"geo",
|
||||
"geo1",
|
||||
"geo2",
|
||||
"hash",
|
||||
"persistent",
|
||||
"primary",
|
||||
"skiplist"
|
||||
};
|
||||
|
||||
// delegate normalization to the 'actualEngine'
|
||||
// FIXME TODO is it actually correct to tie the definition in the Agency to the DBServer engine?
|
||||
for (auto& typeStr: supported_norm) {
|
||||
emplaceNormalizer(
|
||||
typeStr,
|
||||
[](
|
||||
velocypack::Builder& normalized,
|
||||
velocypack::Slice definition,
|
||||
bool isCreation
|
||||
) -> Result {
|
||||
auto* ce = static_cast<ClusterEngine*>(EngineSelectorFeature::ENGINE);
|
||||
|
||||
if (!ce) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
auto* ae = ce->actualEngine();
|
||||
|
||||
if (!ae) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
normalized.clear(); // enhanceIndexDefinition(...) expects an empty open object
|
||||
|
||||
return ae->indexFactory().enhanceIndexDefinition(
|
||||
definition, normalized, isCreation, true
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Result ClusterIndexFactory::enhanceIndexDefinition(VPackSlice const definition,
|
||||
VPackBuilder& normalized,
|
||||
bool isCreation,
|
||||
bool isCoordinator) const {
|
||||
auto* ce = static_cast<ClusterEngine*>(EngineSelectorFeature::ENGINE);
|
||||
|
||||
if (!ce) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
auto* ae = ce->actualEngine();
|
||||
if (!ae) {
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
return ae->indexFactory().enhanceIndexDefinition(definition, normalized,
|
||||
isCreation, isCoordinator);
|
||||
}
|
||||
|
||||
void ClusterIndexFactory::fillSystemIndexes(
|
||||
|
@ -262,4 +235,4 @@ void ClusterIndexFactory::prepareIndexes(
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -31,6 +31,13 @@ class ClusterIndexFactory final : public IndexFactory {
|
|||
public:
|
||||
ClusterIndexFactory();
|
||||
~ClusterIndexFactory() = default;
|
||||
|
||||
Result enhanceIndexDefinition(
|
||||
velocypack::Slice const definition,
|
||||
velocypack::Builder& normalized,
|
||||
bool isCreation,
|
||||
bool isCoordinator
|
||||
) const override;
|
||||
|
||||
void fillSystemIndexes(
|
||||
arangodb::LogicalCollection& col,
|
||||
|
@ -47,4 +54,4 @@ class ClusterIndexFactory final : public IndexFactory {
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -86,7 +86,7 @@ class IndexFactory {
|
|||
IndexNormalizer const& normalizer
|
||||
);
|
||||
|
||||
Result enhanceIndexDefinition(
|
||||
virtual Result enhanceIndexDefinition(
|
||||
velocypack::Slice const definition,
|
||||
velocypack::Builder& normalized,
|
||||
bool isCreation,
|
||||
|
@ -131,4 +131,4 @@ class IndexFactory {
|
|||
|
||||
} // namespace arangodb
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -170,7 +170,7 @@ void CheckVersionFeature::checkVersion() {
|
|||
*_result = 3;
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME)
|
||||
<< "Database version check failed for '" << vocbase->name()
|
||||
<< "': upgrade needed";
|
||||
<< "': downgrade needed";
|
||||
} else if (res.status == methods::VersionResult::UPGRADE_NEEDED &&
|
||||
*_result == 1) {
|
||||
// this is safe to do even if further databases will be checked
|
||||
|
@ -178,7 +178,7 @@ void CheckVersionFeature::checkVersion() {
|
|||
*_result = 2;
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME)
|
||||
<< "Database version check failed for '" << vocbase->name()
|
||||
<< "': downgrade needed";
|
||||
<< "': upgrade needed";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,12 +188,12 @@ void CheckVersionFeature::checkVersion() {
|
|||
if (*_result == 1) {
|
||||
*_result = EXIT_SUCCESS;
|
||||
} else if (*_result > 1) {
|
||||
if (*_result == 2) {
|
||||
if (*_result == 3) {
|
||||
// downgrade needed
|
||||
LOG_TOPIC(FATAL, Logger::FIXME)
|
||||
<< "Database version check failed: downgrade needed";
|
||||
FATAL_ERROR_EXIT_CODE(TRI_EXIT_DOWNGRADE_REQUIRED);
|
||||
} else if (*_result == 3) {
|
||||
} else if (*_result == 2) {
|
||||
LOG_TOPIC(FATAL, Logger::FIXME)
|
||||
<< "Database version check failed: upgrade needed";
|
||||
FATAL_ERROR_EXIT_CODE(TRI_EXIT_UPGRADE_REQUIRED);
|
||||
|
|
|
@ -328,7 +328,7 @@ Result Indexes::ensureIndexCoordinator(
|
|||
}
|
||||
|
||||
Result Indexes::ensureIndex(LogicalCollection* collection,
|
||||
VPackSlice const& definition, bool create,
|
||||
VPackSlice const& input, bool create,
|
||||
VPackBuilder& output) {
|
||||
// can read indexes with RO on db and collection. Modifications require RW/RW
|
||||
ExecContext const* exec = ExecContext::CURRENT;
|
||||
|
@ -346,10 +346,10 @@ Result Indexes::ensureIndex(LogicalCollection* collection,
|
|||
}
|
||||
}
|
||||
|
||||
VPackBuilder defBuilder;
|
||||
VPackBuilder normalized;
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
int res = engine->indexFactory().enhanceIndexDefinition(
|
||||
definition, defBuilder, create, ServerState::instance()->isCoordinator()
|
||||
input, normalized, create, ServerState::instance()->isCoordinator()
|
||||
).errorNumber();
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
|
@ -359,7 +359,7 @@ Result Indexes::ensureIndex(LogicalCollection* collection,
|
|||
TRI_ASSERT(collection);
|
||||
auto& dbname = collection->vocbase().name();
|
||||
std::string const collname(collection->name());
|
||||
VPackSlice indexDef = defBuilder.slice();
|
||||
VPackSlice indexDef = normalized.slice();
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
TRI_ASSERT(indexDef.isObject());
|
||||
|
|
Loading…
Reference in New Issue