Skip to content

Commit ca4a7dd

Browse files
committed
Merge branch 'rc'
2 parents eb20b29 + d860e90 commit ca4a7dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+15378
-8366
lines changed

README.md

+64-56
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)
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,66 +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"
49-
For the [full Documentation](https://terminusdb.github.io/terminusdb-client-js)
47+
This example creates a simple dataProduct, starting to create a database model the schema
48+
and insert a simple document
5049

51-
```javascript
52-
const express = require("express");
53-
const app = express();
54-
const port = 3000;
50+
For the [full Documentation](https://terminusdb.com/docs/reference/js-client)
5551

52+
```javascript
5653
const TerminusClient = require("@terminusdb/terminusdb-client");
5754

5855
// Connect and configure the TerminusClient
59-
const client = new TerminusClient.WOQLClient("https://127.0.0.1:6363/", {
60-
db: "banker",
61-
user: "admin",
62-
key: "root",
63-
});
64-
//to change the starting settings
65-
client.db("banker");
66-
client.organization("admin");
67-
68-
async function postAccount() {
69-
try {
70-
const WOQL = TerminusClient.WOQL;
71-
const query = WOQL.using("admin/banker").and(
72-
WOQL.add_triple("doc:smog", "type", "scm:BankAccount"),
73-
WOQL.add_triple("doc:smog", "owner", "smog"),
74-
WOQL.add_triple("doc:smog", "balance", 999)
75-
);
76-
await client.connect();
77-
client
78-
.query(query, "adding smog's bank account")
79-
.then((response) => {
80-
return response;
81-
})
82-
.catch((err) => {
83-
console.log("error", err);
84-
});
85-
} catch (err) {
86-
console.error(err);
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'})
109+
110+
}catch(err){
111+
console.error(err.message)
112+
}
87113
}
88-
}
89114

90-
app.post("/account", (req, res) => {
91-
postAccount().then((dbres) => res.send(JSON.stringify(dbres)));
92-
});
93-
94-
app.listen(port, () => {
95-
console.log(`Backend Server listening at http://localhost:${port}`);
96-
client
97-
.connect()
98-
.then(function (response) {
99-
// handle success
100-
console.log(response);
101-
})
102-
.catch(function (error) {
103-
// handle error
104-
console.log(error);
105-
});
106-
});
107115
```
108116

109117
## Options
@@ -115,7 +123,7 @@ To initialize `TerminusDB client` with custom options use
115123
```js
116124
const TerminusClient = require("@terminusdb/terminusdb-client");
117125

118-
const client = new TerminusClient.WOQLClient("https://127.0.0.1:6363/", {
126+
const client = new TerminusClient.WOQLClient("http://127.0.0.1:6363/", {
119127
db: "test_db",
120128
user: "admin",
121129
key: "my_secret_key",

docs/README.md

+65-56
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ Promise based terminus client for the browser and node.js
77

88
## Requirements
99

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

1312
## Installation
1413

1514
TerminusDB Client can be used as either a Node.js module available through the npm registry, or directly included in web-sites by including the script tag below.
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,65 +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, starting 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-
const client = new TerminusClient.WOQLClient("https://127.0.0.1:6363/", {
60-
dbid: "banker",
61-
user: "admin",
62-
key: "root",
63-
});
64-
client.db("banker");
65-
client.organization("admin");
66-
67-
async function postAccount() {
68-
try {
69-
const WOQL = TerminusClient.WOQL;
70-
const query = WOQL.using("admin/banker").and(
71-
WOQL.add_triple("doc:smog", "type", "scm:BankAccount"),
72-
WOQL.add_triple("doc:smog", "owner", "smog"),
73-
WOQL.add_triple("doc:smog", "balance", 999)
74-
);
75-
await client.connect();
76-
client
77-
.query(query, "adding smog's bank account")
78-
.then((response) => {
79-
return response;
80-
})
81-
.catch((err) => {
82-
console.log("error", err);
83-
});
84-
} catch (err) {
85-
console.error(err);
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'})
109+
110+
}catch(err){
111+
console.error(err.message)
112+
}
86113
}
87-
}
88114

89-
app.post("/account", (req, res) => {
90-
postAccount().then((dbres) => res.send(JSON.stringify(dbres)));
91-
});
92-
93-
app.listen(port, () => {
94-
console.log(`Backend Server listening at http://localhost:${port}`);
95-
client
96-
.connect()
97-
.then(function (response) {
98-
// handle success
99-
console.log(response);
100-
})
101-
.catch(function (error) {
102-
// handle error
103-
console.log(error);
104-
});
105-
});
106115
```
107116

108117
## Options
@@ -114,8 +123,8 @@ To initialize `TerminusDB client` with custom options use
114123
```js
115124
const TerminusClient = require("@terminusdb/terminusdb-client");
116125

117-
const client = new TerminusClient.WOQLClient("https://127.0.0.1:6363/", {
118-
dbid: "test_db",
126+
const client = new TerminusClient.WOQLClient("http://127.0.0.1:6363/", {
127+
db: "test_db",
119128
user: "admin",
120129
key: "my_secret_key",
121130
});

0 commit comments

Comments
 (0)