Skip to content

Commit 2671d06

Browse files
authored
stream transactions doc (#300)
1 parent 102c9f0 commit 2671d06

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

docs/Drivers/Java/Reference/Collection/DocumentManipulation.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ Retrieves the document with the given \_key from the collection.
5555

5656
Whether or not catch possible thrown exceptions
5757

58+
- **streamTransactionId**: `String`
59+
60+
If set, the operation will be executed within the transaction
61+
5862
**Examples**
5963

6064
```Java
@@ -135,6 +139,10 @@ generated automatically.
135139
will be returned for the created document. This option can be used to save
136140
some network traffic.
137141

142+
- **streamTransactionId**: `String`
143+
144+
If set, the operation will be executed within the transaction
145+
138146
**Examples**
139147

140148
```Java
@@ -190,6 +198,10 @@ generated automatically.
190198
will be returned for the created document. This option can be used to save
191199
some network traffic.
192200

201+
- **streamTransactionId**: `String`
202+
203+
If set, the operation will be executed within the transaction
204+
193205
**Examples**
194206

195207
```Java
@@ -254,6 +266,10 @@ such a document and no precondition is violated.
254266
will be returned for the created document. This option can be used to save
255267
some network traffic.
256268

269+
- **streamTransactionId**: `String`
270+
271+
If set, the operation will be executed within the transaction
272+
257273
**Examples**
258274

259275
```Java
@@ -317,6 +333,10 @@ documents in values.
317333
will be returned for the created document. This option can be used to save
318334
some network traffic.
319335

336+
- **streamTransactionId**: `String`
337+
338+
If set, the operation will be executed within the transaction
339+
320340
**Examples**
321341

322342
```Java
@@ -385,6 +405,10 @@ such a document and no precondition is violated.
385405
will be returned for the created document. This option can be used to save
386406
some network traffic.
387407

408+
- **streamTransactionId**: `String`
409+
410+
If set, the operation will be executed within the transaction
411+
388412
**Examples**
389413

390414
```Java
@@ -448,6 +472,10 @@ documents in values.
448472
will be returned for the created document. This option can be used to save
449473
some network traffic.
450474

475+
- **streamTransactionId**: `String`
476+
477+
If set, the operation will be executed within the transaction
478+
451479
**Examples**
452480

453481
```Java

docs/Drivers/Java/Reference/Database/Queries.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ a new _ArangoCursor_ instance for the result list.
151151
query statistics, warnings and profiling data will only be available after
152152
the query is finished. The default value is false.
153153

154+
- **streamTransactionId**: `String`
155+
156+
If set, the operation will be executed within the transaction
157+
154158
- **type**: `Class<T>`
155159

156160
The type of the result (POJO class, `VPackSlice`, `String` for JSON, or `Collection`/`List`/`Map`)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Transactions
2+
3+
See [HTTP Interface for Stream Transactions](https://docs.arangodb.com/latest/HTTP/transaction-stream-transaction.html).
4+
5+
6+
## ArangoDatabase.beginStreamTransaction
7+
8+
`ArangoDatabase.beginStreamTransaction(StreamTransactionOptions options) : StreamTransactionEntity`
9+
10+
Begins a server-side transaction and returns information about it.
11+
12+
**Arguments**
13+
14+
- **options**: `StreamTransactionOptions`
15+
16+
transaction options
17+
18+
19+
## ArangoDatabase.getStreamTransaction
20+
21+
`ArangoDatabase.getStreamTransaction(String id) : StreamTransactionEntity`
22+
23+
Gets information about a Stream Transaction.
24+
25+
**Arguments**
26+
27+
- **id**: `String`
28+
29+
transaction id
30+
31+
32+
## ArangoDatabase.commitStreamTransaction
33+
34+
`ArangoDatabase.commitStreamTransaction(String id) : StreamTransactionEntity`
35+
36+
Commits a Stream Transaction.
37+
38+
**Arguments**
39+
40+
- **id**: `String`
41+
42+
transaction id
43+
44+
45+
## ArangoDatabase.abortStreamTransaction
46+
47+
`ArangoDatabase.abortStreamTransaction(String id) : StreamTransactionEntity`
48+
49+
Aborts a Stream Transaction.
50+
51+
**Arguments**
52+
53+
- **id**: `String`
54+
55+
transaction id
56+
57+
58+
## Examples
59+
60+
```Java
61+
ArangoDB arango = new ArangoDB.Builder().build();
62+
ArangoDatabase db = arango.db("myDB");
63+
64+
StreamTransactionEntity tx1 = db.beginStreamTransaction(
65+
new StreamTransactionOptions().readCollections("collection").writeCollections("collection"));
66+
db.collection("collection")
67+
.insertDocument(new BaseDocument(), new DocumentCreateOptions().streamTransactionId(tx1.getId()));
68+
db.commitStreamTransaction(tx1.getId());
69+
StreamTransactionEntity tx = db.getStreamTransaction(tx1.getId());
70+
assertThat(tx.getStatus(), is(StreamTransactionEntity.StreamTransactionStatus.committed));
71+
72+
StreamTransactionEntity tx2 = db.beginStreamTransaction(
73+
new StreamTransactionOptions().readCollections("collection").writeCollections("collection"));
74+
final Map<String, Object> bindVars = new HashMap<>();
75+
bindVars.put("@collection", COLLECTION_NAME);
76+
bindVars.put("key", "myKey");
77+
ArangoCursor<BaseDocument> cursor = db
78+
.query("FOR doc IN @@collection FILTER doc._key == @key RETURN doc", bindVars,
79+
new AqlQueryOptions().streamTransactionId(tx2.getId()), BaseDocument.class);
80+
db.abortStreamTransaction(tx2.getId());
81+
```

0 commit comments

Comments
 (0)