8000 doc for insert-update (#291) · arangodb/docs@5a7f54f · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit 5a7f54f

Browse files
authored
doc for insert-update (#291)
1 parent 1aa72e9 commit 5a7f54f

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

3.7/aql/operations-insert.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ FOR i IN 1..1000
104104
} INTO users OPTIONS { overwrite: true }
105105
```
106106

107+
To update existing documents with documents having the same key there is the
108+
*overwriteMode* query option, which implicitly enables the *overwrite* option .
8000
109+
This will let you choose between "replace" and "update" overwrite mode. In case
110+
the *overwriteMode* is "update" the *keepNull* and *mergeObjects* options will
111+
modify how the replacement is done. See the [UPDATE operation](operations-update.html#setting-query-options)
112+
for more detail on these options.
113+
114+
```js
115+
FOR i IN 1..1000
116+
INSERT {
117+
_key: CONCAT('test', i),
118+
name: "test",
119+
foobar: true
120+
} INTO users OPTIONS { overwriteMode: "update", keepNull: true, mergeObjects: false }
121+
```
122+
107123
In contrast to the MMFiles engine, the RocksDB engine does not require collection-level
108124
locks. Different write operations on the same collection do not block each other, as
109125
long as there are no _write-write conficts_ on the same documents. From an application

3.7/data-modeling-documents-document-methods.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,33 @@ used to specify the following options:
609609
a default *waitForSync* value of *true*.
610610
- *silent*: If this flag is set to *true*, the method does not return
611611
any output.
612-
- *overwrite*: If set to *true*, the insert becomes a replace-insert.
613-
If a document with the same *_key* already exists the new document
614-
is not rejected with unique constraint violated but will replace
615-
the old document.
616612
- *returnNew*: If this flag is set to *true*, the complete new document
617613
is returned in the output under the attribute *new*.
618614
- *returnOld*: If this flag is set to *true*, the complete old document
619615
is returned in the output under the attribute *old*. Only available
620616
in combination with the *overwrite* option
617+
- *overwrite*: If set to *true*, the insert becomes a replace-insert.
618+
If a document with the same *_key* already exists the new document
619+
is not rejected with unique constraint violated but will replace
620+
the old document.
621+
- *overwriteMode*: If this optional flag is set to *replace* or *update*,
622+
it implicitly activates the *overwrite* mode. In case it is set to
623+
*update*, the replace-insert becomes an update-insert.
624+
Otherwise this option follows the rules of the overwrite parameter.
625+
The *update* operation can be controlled by the *keepNull* and
626+
*mergeObjects* parameters.
627+
- *keepNull*: The optional *keepNull* parameter can be used to modify
628+
the behavior when handling *null* values. Normally, *null* values
629+
are stored in the database. By setting the *keepNull* parameter to
630+
*false*, this behavior can be changed so that all attributes in
631+
*data* with *null* values will be removed from the target document.
632+
This option controls the update-insert behavior only.
633+
- *mergeObjects*: Controls whether objects (not arrays) will be
634+
merged if present in both the existing and the patch document. If
635+
set to *false*, the value in the patch document will overwrite the
636+
existing document's value. If set to *true*, objects will be merged.
637+
The default is *true*.
638+
This option controls the update-insert behavior only.
621639

622640
`collection.insert(array)`
623641

@@ -1433,4 +1451,4 @@ as second argument.
14331451
@END_EXAMPLE_ARANGOSH_OUTPUT
14341452
@endDocuBlock accessViaGeoIndex
14351453
{% endarangoshexample %}
1436-
{% include arangoshexample.html id=examplevar script=script result=result %}
1454+
{% include arangoshexample.html id=examplevar script=script result=result %}

3.7/release-notes-new-features37.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ Additionally the `/_admin/server/jwt` API can be used to reload the JWT secrets
9494
of a local arangod process without having to restart it (hot-reload). This may
9595
be used to roll out new JWT secrets throughout an ArangoDB cluster.
9696

97+
### Insert-Update
98+
99+
ArangoDB 3.7 adds an insert-update operation that is similar to the already
100+
existing insert-replace functionality. A new `overwriteMode` flag has been
101+
introduced to control the type of the overwrite operation in case of colliding
102+
keys during the insert.
103+
104+
In the case of `overwriteMode: "update"`, the parameters `keepNull` and
105+
`mergeObjects` can be provided to control the update operation.
106+
107+
The query options are available in [AQL](aql/operations-insert.html#setting-query-options),
108+
the [JS API](data-modeling-documents-document-methods.html#insert--save) and
109+
[HTTP API](http/document-working-with-documents.html#create-document).
110+
97111
JavaScript API
98112
--------------
99113

0 commit comments

Comments
 (0)
0