Skip to content

Commit d46f7e7

Browse files
committed
Merge branch 'main' into fix_integration
2 parents 3964a0b + 8a7259a commit d46f7e7

File tree

6 files changed

+36
-17
lines changed

6 files changed

+36
-17
lines changed

docs/api/typedef.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ the PUT document interface query parameters
4747
| Name | Type | Description |
4848
| --- | --- | --- |
4949
| [raw_json] | <code>boolean</code> | default is false, If true, the input documents are treated as raw JSON, inserted as type sys:JSONDocument and are not subject to schema restrictions. |
50+
| [create] | <code>boolean</code> | If true, the function will create a new document if it doesn't exist. |
5051
| [graph_type] | <code>GraphType</code> | default is instance, instance|schema Used to switch between getting documents from the instance or the schema graph. |
5152

5253

@@ -60,7 +61,7 @@ the DELETE document interface query parameters
6061
| --- | --- | --- |
6162
| [graph_type] | <code>GraphType</code> | default is instance, instance|schema Used to switch between getting documents from the instance or the schema graph. |
6263
| id | <code>string</code> \| <code>array</code> | a single id or a list of ids to delete. |
63-
| [nuke] | <code>booleam</code> | default is false, If true, delete everything at this resource location (dangerous!). |
64+
| [nuke] | <code>boolean</code> | default is false, If true, delete everything at this resource location (dangerous!). |
6465

6566

6667
## GraphRef

docs/api/woql.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1455,8 +1455,10 @@ const doc = WOQL.doc({ "@type": "Person", name: "Newperson" })
14551455
```
14561456

14571457
## client
1458-
##### WOQL.client(client) ⇒ <code>WOQLClient</code>
1459-
Gets/Sets woqlClient
1458+
##### ~~WOQL.client(client) ⇒ <code>WOQLClient</code>~~
1459+
***Deprecated***
1460+
1461+
Use instead to run your query woqlclient.query('myWOQLQuery')
14601462

14611463

14621464
| Param | Type |

docs/api/woqlclient.md

+18-9
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,8 @@ async function getSchema() {
5555
##### ~~woqlClient.connect([params]) ⇒ <code>Promise</code>~~
5656
***Deprecated***
5757

58-
Connect to a Terminus server at the given URI with an API key
59-
Stores the system:ServerCapability document returned
60-
in the connection register which stores, the url, key, capabilities,
61-
and database meta-data for the connected server
62-
this.connectionConfig.server will be used if present,
58+
You can call this to get the server info or override the start params
59+
configuration, this.connectionConfig.server will be used if present,
6360
or the promise will be rejected.
6461

6562
**Returns**: <code>Promise</code> - the connection capabilities response object or an error object
@@ -863,8 +860,8 @@ client.getDocument({"graph_type":"schema","as_list":true,"id":"Country"}).then(r
863860
})
864861

865862
//pass a document query template to query the document interface
866-
const queryTemplate = { "name": "Ireland", "@type":"Country" }
867-
client.getDocument({"graph_type":"schema","as_list":true,
863+
const queryTemplate = { "name": "Ireland"}
864+
client.getDocument({"as_list":true, "@type":"Country"
868865
query:queryTemplate}).then(result=>{
869866
console.log(result)
870867
})
@@ -896,7 +893,7 @@ const response1 = await client.getDocument({"graph_type":"schema","as_list":true
896893
```
897894
898895
## updateDocument
899-
##### woqlClient.updateDocument(json, [params], [dbId], [message], [lastDataVersion], [getDataVersion], [create]) ⇒ <code>Promise</code>
896+
##### woqlClient.updateDocument(json, [params], [dbId], [message], [lastDataVersion], [getDataVersion], [compress], [create]) ⇒ <code>Promise</code>
900897
**Returns**: <code>Promise</code> - A promise that returns the call response object or object having *result*
901898
and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
902899
@@ -908,7 +905,8 @@ and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error
908905
| [message] | <code>\*</code> | the update commit message |
909906
| [lastDataVersion] | <code>string</code> | the last data version tracking id. |
910907
| [getDataVersion] | <code>boolean</code> | If true the function will return object having result and dataVersion. |
911-
| [create] | <code>boolean</code> | If true, the function will create a new document if it doesn't exist. |
908+
| [compress] | <code>boolean</code> | If true, the function will create a new document if it doesn't exist. |
909+
| [create] | <code>boolean</code> | Perform an *upsert* which inserts if the document is not present (also works on nested documents) |
912910
913911
**Example**
914912
```javascript
@@ -967,6 +965,17 @@ const response1 = await client.updateDocument(
967965
"",
968966
response.dataVersion
969967
);
968+
969+
// update a document and create the linked document together
970+
// we are update the document "Person/Person01"
971+
// and create a new document {"@type": "Person","name": "child01"} at the same time
972+
const response1 = await client.updateDocument(
973+
{
974+
"@id": "Person/Person01",
975+
"@type": "Person",
976+
"name": "Person01"
977+
"children":[{"@type": "Person","name": "child01"}]
978+
},{create:true})
970979
```
971980
972981
## deleteDocument

lib/query/woqlDoc.js

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ function convert(obj) {
7272
*/
7373
function Var(name) {
7474
this.name = name;
75+
this.json = function () {
76+
return {
77+
'@type': 'Value',
78+
variable: this.name,
79+
};
80+
};
7581
}
7682

7783
/**

lib/woqlClient.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,10 @@ WOQLClient.prototype.squashBranch = function (branchId, commitMsg) {
750750
WOQLClient.prototype.resetBranch = function (branchId, commitId) {
751751
if (commitId && branchId) {
752752
// eslint-disable-next-line camelcase
753-
const commit_descriptor = this.generateCommitDescriptor(commitId);
754753
return this.dispatch(
755754
CONST.RESET_BRANCH,
756755
this.connectionConfig.resetBranchUrl(branchId),
757-
commit_descriptor,
756+
{ commit_descriptor: commitId },
758757
);
759758
}
760759
const errmsg = 'Branch parameter error - you must specify a valid new branch id and a commit message';
@@ -1227,7 +1226,9 @@ WOQLClient.prototype.getDocument = function (params, dbId, branch, lastDataVersi
12271226
* @param {string} [lastDataVersion] the last data version tracking id.
12281227
* @param {boolean} [getDataVersion] If true the function will return object having result
12291228
* and dataVersion.
1230-
* @param {boolean} [create] If true, the function will create a new document if it doesn't exist.
1229+
* @param {boolean} [compress] If true, the function will create a new document if it doesn't exist.
1230+
* @param {boolean} [create] Perform an *upsert* which inserts if the document
1231+
* is not present (also works on nested documents)
12311232
* @returns {Promise} A promise that returns the call response object or object having *result*
12321233
* and *dataVersion* object if ***getDataVersion*** parameter is true, or an Error if rejected.
12331234
* @example

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)