Skip to content

Commit 0a262c2

Browse files
Add create query parameter for update document (#189)
1 parent 3f995af commit 0a262c2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/api/woqlclient.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ const response1 = await client.getDocument({"graph_type":"schema","as_list":true
856856
```
857857
858858
## updateDocument
859-
##### woqlClient.updateDocument(json, [params], [dbId], [message], [lastDataVersion], [getDataVersion]) ⇒ <code>Promise</code>
859+
##### woqlClient.updateDocument(json, [params], [dbId], [message], [lastDataVersion], [getDataVersion], [create]) ⇒ <code>Promise</code>
860860
**Returns**: <code>Promise</code> - A promise that returns the call response object or object having *result*
861861
and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
862862
@@ -868,6 +868,7 @@ and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error
868868
| [message] | <code>\*</code> | the update commit message |
869869
| [lastDataVersion] | <code>string</code> | the last data version tracking id. |
870870
| [getDataVersion] | <code>boolean</code> | If true the function will return object having result and dataVersion. |
871+
| [create] | <code>boolean</code> | If true, the function will create a new document if it doesn't exist. |
871872
872873
**Example**
873874
```javascript

lib/woqlClient.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ WOQLClient.prototype.getDocument = function (params, dbId, branch, lastDataVersi
11501150
* @param {string} [lastDataVersion] the last data version tracking id.
11511151
* @param {boolean} [getDataVersion] If true the function will return object having result
11521152
* and dataVersion.
1153+
* @param {boolean} [create] If true, the function will create a new document if it doesn't exist.
11531154
* @returns {Promise} A promise that returns the call response object or object having *result*
11541155
* and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
11551156
* @example
@@ -1210,10 +1211,11 @@ WOQLClient.prototype.getDocument = function (params, dbId, branch, lastDataVersi
12101211
);
12111212
*/
12121213

1213-
WOQLClient.prototype.updateDocument = function (json, params, dbId, message = 'update document', lastDataVersion = '', getDataVersion = false, compress = false) {
1214+
WOQLClient.prototype.updateDocument = function (json, params, dbId, message = 'update document', lastDataVersion = '', getDataVersion = false, compress = false, create = false) {
12141215
const docParams = params || {};
12151216
docParams.author = this.author();
12161217
docParams.message = message;
1218+
docParams.create = create;
12171219
if (dbId) {
12181220
this.db(dbId);
12191221
}

0 commit comments

Comments
 (0)