@@ -43,7 +43,7 @@ const TerminusClient = require('@terminusdb/terminus-client');
43
43
const client = new TerminusClient.WOQLClient ();
44
44
45
45
// Connect to a Terminus server at the given URI with an API key
46
- client .connect (" http://localhost/" , ' secret' ).
46
+ client .connect (" http://localhost:6363 /" , ' secret' ).
47
47
.then (function (response ) {
48
48
// handle success
49
49
console .log (response);
@@ -60,7 +60,7 @@ client.connect("http://localhost/", 'secret').
60
60
// use async/await.
61
61
async function getCapabilities () {
62
62
try {
63
- const response = await client .connect (" http://localhost/" , ' secret' );
63
+ const response = await client .connect (" http://localhost:6363 /" , ' secret' );
64
64
console .log (response);
65
65
} catch (err) {
66
66
console .error (err);
@@ -89,30 +89,35 @@ const client = new TerminusClient.WOQLClient({
89
89
90
90
## API
91
91
92
- ### ` createDatabase([dburl:String, details:Object, key:String]):Object `
92
+ ##### ` createDatabase([dburl:String, details:Object, key:String]):Object `
93
93
Create a new terminusDB database in the current terminusDB server
94
94
95
95
``` js
96
96
var currentTerminusServerUrl= client .connectionConfig .dbURL ();
97
97
98
- var details= {
99
- " @context" : {
98
+ var details= {
99
+ " @context" : {
100
100
" rdfs" : " http://www.w3.org/2000/01/rdf-schema#" ,
101
- " terminus" : " https://datachemist.net/ontology/terminus#"
101
+ " terminus" : " http://terminusdb.com/schema/terminus#" ,
102
+ " _" : " http://localhost:6363/test_new_db/"
102
103
},
103
- " @type" : " terminus:Database" ,
104
- " rdfs:label" : {
105
- " @language" : " en" ,
106
- " @value" : " test 01"
104
+ " terminus:document" : {
105
+ " @type" : " terminus:Database" ,
106
+ " rdfs:label" : {
107
+ " @language" : " en" ,
108
+ " @value" : " new db tests"
109
+ },
110
+ " rdfs:comment" : {
111
+ " @language" : " en" ,
112
+ " @value" : " new db description"
113
+ },
114
+ " terminus:allow_origin" : {
115
+ " @type" : " xsd:string" ,
116
+ " @value" : " *"
117
+ },
118
+ " @id" : " http://localhost:6363/test_new_db"
107
119
},
108
- " rdfs:comment" : {
109
- " @language" : " en" ,
110
- " @value" : " description"
111
- },
112
- " terminus:allow_origin" : {
113
- " @type" : " xsd:string" ,
114
- " @value" : " *"
115
- }
120
+ " @type" : " terminus:APIUpdate"
116
121
}
117
122
118
123
@@ -122,12 +127,12 @@ client.createDatabase("newD",details,'root');
122
127
123
128
```
124
129
125
- ### ` deleteDatabase():{[dbUrl:string]} `
130
+ ##### ` deleteDatabase():{[dbUrl:string]} `
126
131
For delete a terminusDB
127
132
128
133
``` js
129
134
// if authorized you can delete a terminusDB in the server myTerminusServer
130
- client .deleteDatabase (" http://myTerminusServer /dbID" );
135
+ client .deleteDatabase (" http://localhost:6363 /dbID" );
131
136
132
137
or
133
138
@@ -137,6 +142,54 @@ client.deleteDatabase("dbID");
137
142
138
143
```
139
144
145
+ ##### ` getSchema():{[schurl:String, opts:Object]} `
146
+ For get a terminusDB schema
147
+
148
+ ``` js
149
+
150
+ // Retrieves the schema of the specified database by Full Url
151
+ client .getSchema (" http://localhost:6363/dbID" );
152
+
153
+ or
154
+
155
+ // you can get a database schema in the current seleted server
156
+ client .getSchema (" dbID" ).then ((response )=> {
157
+ console .log (" response" )
158
+ }).catch ((err )=> {
159
+ console .log (err);
160
+ });
161
+ ...
162
+
163
+ ```
164
+
165
+ //https://github.com/terminusdb/terminus-schema
166
+ const opts={terminus:encoding: "terminus: turtle "}
167
+
168
+
169
+ ##### ` updateSchema():{[schurl:String, doc:String, opts:Object]) `
170
+ For Update a terminusDB schema
171
+ schurl TerminusDB server URL or a valid TerminusDB Id or omitted
172
+ doc is OWL schema String
173
+ Some example[ TerminusDB OWL Schema] (https://github.com/terminusdb/terminus-schema )
174
+
175
+ ``` js
176
+
177
+ const doc = " @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.........."
178
+
179
+ const opts = {terminus: encoding: " terminus:turtle" }
180
+
181
+ client .updateSchema (false ,doc,opts).then ((response )=> {
182
+ console .log (response)
183
+ }).catch ((err )=> {
184
+ console .log (err)
185
+ });
186
+
187
+ ...
188
+
189
+ ```
190
+
191
+
192
+
140
193
141
194
## Testing
142
195
* Clone this repository
0 commit comments