Skip to content

Commit d387132

Browse files
committed
review docs
1 parent 26e6024 commit d387132

File tree

9 files changed

+155
-365
lines changed

9 files changed

+155
-365
lines changed

README.md

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Promise based terminus client for the browser and node.js
77

88
## Requirements
99

10-
- [TerminusDB](https://github.com/terminusdb/terminusdb-server)
1110
- [NodeJS 10+](https://nodejs.org/en/)
1211

1312
## Installation
@@ -16,7 +15,8 @@ TerminusDB Client can be used as either a Node.js module available through the n
1615

1716
### NPM Module
1817

19-
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
18+
Before installing, download and install Node.js.<br>
19+
NodeJS version 10.X or higher is required. NodeJS version 14.X is recommended.
2020

2121
Installation is done using the npm install command:
2222

@@ -44,53 +44,74 @@ Download the terminusdb-client.min.js file from the /dist directory and save it
4444

4545
## Usage
4646

47-
This example creates a simple Express.js server that will post an account to
48-
a database with the id "banker" and the default "admin" user with password "root"
47+
This example creates a simple dataProduct, staring to create a database model the schema
48+
and insert a simple document
49+
4950
For the [full Documentation](https://terminusdb.com/docs/reference/js-client)
5051

5152
```javascript
52-
const express = require("express");
53-
const app = express();
54-
const port = 3000;
55-
5653
const TerminusClient = require("@terminusdb/terminusdb-client");
5754

5855
// Connect and configure the TerminusClient
59-
60-
// Connect and configure the TerminusClient
61-
const client = new TerminusClient.WOQLClient("http://127.0.0.1:6363/", {
62-
user: "admin",
63-
key: "root",
64-
db:"mydb",
65-
});
66-
67-
//change database, set the banker database
68-
client.db("banker");
69-
70-
//we are insert the data in the banker db
71-
app.post("/account", async(req, res) => {
72-
try{
73-
const owner = req.body.owner
74-
const balance = req.body.balance
75-
const accountObj = {'@type':'BankAccount',
76-
'owner':owner,
77-
'balance':balance}
78-
79-
80-
await client.connect()
81-
const response = await client.addDocument(accountObj)
82-
res.json({message:'account added'})
56+
const client = new TerminusClient.WOQLClient('SERVER_CLOUD_URL/mycloudTeam',
57+
{user:"myemail@something.com", organization:'mycloudTeam'})
58+
59+
client.setApiKey(MY_ACCESS_TOKEN)
60+
61+
const bankerSchema = [
62+
{
63+
"@type":"Class",
64+
"@id":"BankAccount",
65+
"@key":{
66+
"@type":"Hash",
67+
"@fields":[
68+
"account_id"
69+
]
70+
},
71+
"account_id":"xsd:string",
72+
"owner":"Person",
73+
"balance":"xsd:decimal"
74+
},
75+
{
76+
"@type":"Class",
77+
"@id":"Person",
78+
"@key":{
79+
"@type":"Hash",
80+
"@fields":[
81+
"name"
82+
]
83+
},
84+
"name":"xsd:string"
85+
}
86+
]
87+
88+
async function createDataProduct(){
89+
try{
90+
await client.connect()
91+
await client.createDatabase("banker", {label: "Banker Account",
92+
comment: "Testing", schema: true})
93+
//add the schema documents
94+
await client.addDocument(bankerSchema,{"graph_type":"schema"},null,"add new schema")
95+
96+
const accountObj = {"@type":"BankAccount",
97+
"account_id":"DBZDFGET23456",
98+
"owner":{
99+
"@type":"Person",
100+
"name":"Tom"
101+
},
102+
"balance":1000
103+
}
104+
105+
//add a document instance
106+
await client.addDocument(accountObj)
107+
108+
client.getDocument({"as_list":true,id:'Person/Tom'})
83109

84110
}catch(err){
85111
console.error(err.message)
86-
const status=err.status || 500
87-
res.status(status).send({message: 'Failed to add a new account','err':err.message});
88112
}
89-
})
113+
}
90114

91-
app.listen(port, () => {
92-
console.log(`Backend Server listening at http://localhost:${port}`);
93-
});
94115
```
95116

96117
## Options

docs/README.md

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Promise based terminus client for the browser and node.js
77

88
## Requirements
99

10-
- [TerminusDB](https://github.com/terminusdb/terminusdb-server)
1110
- [NodeJS 10+](https://nodejs.org/en/)
1211

1312
## Installation
@@ -16,7 +15,8 @@ TerminusDB Client can be used as either a Node.js module available through the n
1615

1716
### NPM Module
1817

19-
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
18+
Before installing, download and install Node.js.<br>
19+
NodeJS version 10.X or higher is required. NodeJS version 14.X is recommended.
2020

2121
Installation is done using the npm install command:
2222

@@ -44,53 +44,74 @@ Download the terminusdb-client.min.js file from the /dist directory and save it
4444

4545
## Usage
4646

47-
This example creates a simple Express.js server that will post an account to
48-
a database with the id "banker" and the default "admin" user with password "root"
47+
This example creates a simple dataProduct, staring to create a database model the schema
48+
and insert a simple document
49+
4950
For the [full Documentation](https://terminusdb.com/docs/reference/js-client)
5051

5152
```javascript
52-
const express = require("express");
53-
const app = express();
54-
const port = 3000;
55-
5653
const TerminusClient = require("@terminusdb/terminusdb-client");
5754

5855
// Connect and configure the TerminusClient
59-
60-
// Connect and configure the TerminusClient
61-
const client = new TerminusClient.WOQLClient("http://127.0.0.1:6363/", {
62-
user: "admin",
63-
key: "root",
64-
db:"mydb",
65-
});
66-
67-
//change database, set the banker database
68-
client.db("banker");
69-
70-
//we are insert the data in the banker db
71-
app.post("/account", async(req, res) => {
72-
try{
73-
const owner = req.body.owner
74-
const balance = req.body.balance
75-
const accountObj = {'@type':'BankAccount',
76-
'owner':owner,
77-
'balance':balance}
78-
79-
80-
await client.connect()
81-
const response = await client.addDocument(accountObj)
82-
res.json({message:'account added'})
56+
const client = new TerminusClient.WOQLClient('SERVER_CLOUD_URL/mycloudTeam',
57+
{user:"myemail@something.com", organization:'mycloudTeam'})
58+
59+
client.setApiKey(MY_ACCESS_TOKEN)
60+
61+
const bankerSchema = [
62+
{
63+
"@type":"Class",
64+
"@id":"BankAccount",
65+
"@key":{
66+
"@type":"Hash",
67+
"@fields":[
68+
"account_id"
69+
]
70+
},
71+
"account_id":"xsd:string",
72+
"owner":"Person",
73+
"balance":"xsd:decimal"
74+
},
75+
{
76+
"@type":"Class",
77+
"@id":"Person",
78+
"@key":{
79+
"@type":"Hash",
80+
"@fields":[
81+
"name"
82+
]
83+
},
84+
"name":"xsd:string"
85+
}
86+
]
87+
88+
async function createDataProduct(){
89+
try{
90+
await client.connect()
91+
await client.createDatabase("banker", {label: "Banker Account",
92+
comment: "Testing", schema: true})
93+
//add the schema documents
94+
await client.addDocument(bankerSchema,{"graph_type":"schema"},null,"add new schema")
95+
96+
const accountObj = {"@type":"BankAccount",
97+
"account_id":"DBZDFGET23456",
98+
"owner":{
99+
"@type":"Person",
100+
"name":"Tom"
101+
},
102+
"balance":1000
103+
}
104+
105+
//add a document instance
106+
await client.addDocument(accountObj)
107+
108+
client.getDocument({"as_list":true,id:'Person/Tom'})
83109

84110
}catch(err){
85111
console.error(err.message)
86-
const status=err.status || 500
87-
res.status(status).send({message: 'Failed to add a new account','err':err.message});
88112
}
89-
})
113+
}
90114

91-
app.listen(port, () => {
92-
console.log(`Backend Server listening at http://localhost:${port}`);
93-
});
94115
```
95116

96117
## Options

docs/_sidebar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
- [update_quad](api/woql.js?id=update_quad)
158158
- [value](api/woql.js?id=value)
159159
- [link](api/woql.js?id=link)
160+
- [ParamType](api/typedef.js?id=typedef)
160161
- [DocParamsGet](api/typedef.js?id=DocParamsGet)
161162
- [DocParamsPost](api/typedef.js?id=DocParamsPost)
162163
- [DocParamsPut](api/typedef.js?id=DocParamsPut)
@@ -176,5 +177,4 @@
176177
- [DbDetails](api/typedef.js?id=DbDetails)
177178
- [RemoteRepoDetails](api/typedef.js?id=RemoteRepoDetails)
178179
- [CloneSourceDetails](api/typedef.js?id=CloneSourceDetails)
179-
- [ParamType](api/typedef.js?id=typedef)
180180

docs/api _master/typedef.js.md

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,5 @@
11
## Typedefs
22

3-
<dl>
4-
<dt><a href="#GraphRef">GraphRef</a> : <code>&quot;schema/main&quot;</code> | <code>&quot;schema/*&quot;</code> | <code>&quot;instance/main&quot;</code> | <code>&quot;instance/*&quot;</code> | <code>&quot;inference/main&quot;</code> | <code>&quot;inference/*&quot;</code> | <code>string</code></dt>
5-
<dd></dd>
6-
<dt><a href="#DataFormatObj">DataFormatObj</a> : <code>Object</code></dt>
7-
<dd><p>(export/import)</p>
8-
</dd>
9-
<dt><a href="#FuntionType">FuntionType</a> : <code>&quot;add_quad&quot;</code> | <code>&quot;delete_quad&quot;</code> | <code>&quot;add_triple&quot;</code> | <code>&quot;delete_triple&quot;</code> | <code>&quot;quad&quot;</code> | <code>&quot;triple&quot;</code></dt>
10-
<dd></dd>
11-
<dt><a href="#ClassObj">ClassObj</a> : <code>Object</code></dt>
12-
<dd><p>the class details object</p>
13-
</dd>
14-
<dt><a href="#PropertyObj">PropertyObj</a> : <code>Object</code></dt>
15-
<dd><p>an object that describe a property element</p>
16-
</dd>
17-
<dt><a href="#ResourceType">ResourceType</a> : <code>&quot;commits&quot;</code> | <code>&quot;meta&quot;</code> | <code>&quot;branch&quot;</code> | <code>&quot;ref&quot;</code> | <code>&quot;repo&quot;</code> | <code>&quot;db&quot;</code></dt>
18-
<dd></dd>
19-
<dt><a href="#GraphType">GraphType</a> : <code>&quot;inference&quot;</code> | <code>&quot;schema&quot;</code> | <code>&quot;instance&quot;</code></dt>
20-
<dd></dd>
21-
<dt><a href="#CredentialObj">CredentialObj</a> : <code>Object</code></dt>
22-
<dd></dd>
23-
<dt><a href="#ActionType">ActionType</a> : <code>&#x27;graph&#x27;</code> | <code>&#x27;db&#x27;</code> | <code>&#x27;clone&#x27;</code> | <code>&#x27;triples&#x27;</code> | <code>&#x27;woql&#x27;</code> | <code>&#x27;frame&#x27;</code> | <code>&#x27;fetch&#x27;</code> | <code>&#x27;pull&#x27;</code> | <code>&#x27;rebase&#x27;</code> | <code>&#x27;csv&#x27;</code> | <code>&#x27;branch&#x27;</code> | <code>&#x27;reset&#x27;</code> | <code>&#x27;push&#x27;</code> | <code>&#x27;squash&#x27;</code></dt>
24-
<dd></dd>
25-
<dt><a href="#ParamsObj">ParamsObj</a> : <code>Object</code></dt>
26-
<dd></dd>
27-
<dt><a href="#RolesObj">RolesObj</a> : <code>Object</code></dt>
28-
<dd></dd>
29-
<dt><a href="#RepoType">RepoType</a> : <code>&quot;local&quot;</code> | <code>&quot;remote&quot;</code></dt>
30-
<dd></dd>
31-
<dt><a href="#DbDetails">DbDetails</a> : <code>Object</code></dt>
32-
<dd></dd>
33-
<dt><a href="#RemoteRepoDetails">RemoteRepoDetails</a> : <code>Object</code></dt>
34-
<dd><p>{remote: &quot;origin&quot;, &quot;remote_branch&quot;: &quot;main&quot;, &quot;author&quot;: &quot;admin&quot;, &quot;message&quot;: &quot;message&quot;}</p>
35-
</dd>
36-
<dt><a href="#CloneSourceDetails">CloneSourceDetails</a> : <code>Object</code></dt>
37-
<dd></dd>
38-
</dl>
39-
40-
413
## GraphRef
424
#### GraphRef : <code>&quot;schema/main&quot;</code> \| <code>&quot;schema/\*&quot;</code> \| <code>&quot;instance/main&quot;</code> \| <code>&quot;instance/\*&quot;</code> \| <code>&quot;inference/main&quot;</code> \| <code>&quot;inference/\*&quot;</code> \| <code>string</code>
435

docs/api/typedef.js.md

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ the DELETE document interface query parameters
5757

5858

5959
## GraphRef
60-
#### GraphRef : <code>&quot;schema/main&quot;</code> \| <code>&quot;schema/\*&quot;</code> \| <code>&quot;instance/main&quot;</code> \| <code>&quot;instance/\*&quot;</code> \| <code>&quot;inference/main&quot;</code> \| <code>&quot;inference/\*&quot;</code> \| <code>string</code>
60+
#### GraphRef : <code>&quot;schema/main&quot;</code> \| <code>&quot;instance/main&quot;</code> \| <code>string</code>
6161

6262
## DataFormatObj
6363
#### DataFormatObj : <code>Object</code>
@@ -74,45 +74,11 @@ the DELETE document interface query parameters
7474
## FuntionType
7575
#### FuntionType : <code>&quot;add\_quad&quot;</code> \| <code>&quot;delete\_quad&quot;</code> \| <code>&quot;add\_triple&quot;</code> \| <code>&quot;delete\_triple&quot;</code> \| <code>&quot;quad&quot;</code> \| <code>&quot;triple&quot;</code>
7676

77-
## ClassObj
78-
#### ClassObj : <code>Object</code>
79-
the class details object
80-
81-
**Properties**
82-
83-
| Name | Type | Description |
84-
| --- | --- | --- |
85-
| id | <code>string</code> | IRI or variable containing IRI of the class to be inserted |
86-
| [label] | <code>string</code> | |
87-
| [description] | <code>string</code> | |
88-
| [abstract] | <code>boolean</code> | |
89-
| [parent] | <code>array</code> \| <code>string</code> | if not parent the new class will be a class ObjectW |
90-
| [{k:string}] | <code>any</code> | properties |
91-
92-
93-
## PropertyObj
94-
#### PropertyObj : <code>Object</code>
95-
an object that describe a property element
96-
97-
**Properties**
98-
99-
| Name | Type | Description |
100-
| --- | --- | --- |
101-
| id | <code>string</code> | |
102-
| range | <code>string</code> | the type of property (class id or a native type xsd:number etc.. ) |
103-
| [label] | <code>string</code> | |
104-
| [description] | <code>string</code> | |
105-
| domain | <code>string</code> | the ID of the class to which the property belongs |
106-
| [max] | <code>string</code> | the max property's cardinality |
107-
| [min] | <code>string</code> | the min property's cardinality |
108-
| [cardinality] | <code>string</code> | the property cardinality (max and min value) |
109-
110-
11177
## ResourceType
11278
#### ResourceType : <code>&quot;commits&quot;</code> \| <code>&quot;meta&quot;</code> \| <code>&quot;branch&quot;</code> \| <code>&quot;ref&quot;</code> \| <code>&quot;repo&quot;</code> \| <code>&quot;db&quot;</code>
11379

11480
## GraphType
115-
#### GraphType : <code>&quot;inference&quot;</code> \| <code>&quot;schema&quot;</code> \| <code>&quot;instance&quot;</code>
81+
#### GraphType : <code>&quot;schema&quot;</code> \| <code>&quot;instance&quot;</code>
11682

11783
## CredentialObj
11884
#### CredentialObj : <code>Object</code>
@@ -126,7 +92,7 @@ an object that describe a property element
12692

12793

12894
## ActionType
129-
#### ActionType : <code>&#x27;graph&#x27;</code> \| <code>&#x27;db&#x27;</code> \| <code>&#x27;clone&#x27;</code> \| <code>&#x27;triples&#x27;</code> \| <code>&#x27;woql&#x27;</code> \| <code>&#x27;frame&#x27;</code> \| <code>&#x27;fetch&#x27;</code> \| <code>&#x27;pull&#x27;</code> \| <code>&#x27;rebase&#x27;</code> \| <code>&#x27;csv&#x27;</code> \| <code>&#x27;branch&#x27;</code> \| <code>&#x27;reset&#x27;</code> \| <code>&#x27;push&#x27;</code> \| <code>&#x27;squash&#x27;</code>
95+
#### ActionType : <code>&#x27;graph&#x27;</code> \| <code>&#x27;db&#x27;</code> \| <code>&#x27;clone&#x27;</code> \| <code>&#x27;triples&#x27;</code> \| <code>&#x27;woql&#x27;</code> \| <code>&#x27;fetch&#x27;</code> \| <code>&#x27;pull&#x27;</code> \| <code>&#x27;rebase&#x27;</code> \| <code>&#x27;branch&#x27;</code> \| <code>&#x27;reset&#x27;</code> \| <code>&#x27;push&#x27;</code> \| <code>&#x27;squash&#x27;</code>
13096

13197
## ParamsObj
13298
#### ParamsObj : <code>Object</code>

0 commit comments

Comments
 (0)