Skip to content

Commit 1b07b9a

Browse files
committed
change readme doc
1 parent b5d9a0e commit 1b07b9a

File tree

2 files changed

+95
-11
lines changed

2 files changed

+95
-11
lines changed

Readme.md

Lines changed: 93 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,11 @@ Create a new terminusDB database
105105

106106

107107
var details={
108-
"@context":{
108+
"@context":{
109109
"rdfs":"http://www.w3.org/2000/01/rdf-schema#",
110110
"terminus":"http://terminusdb.com/schema/terminus#",
111111
"_":"http://localhost:6363/myFirstTerminusDB/"
112-
},
113-
"terminus:document":{
112+
},
114113
"@type":"terminus:Database",
115114
"rdfs:label":{
116115
"@language":"en",
@@ -125,9 +124,7 @@ var details={
125124
"@value":"*"
126125
},
127126
"@id":"http://localhost:6363/myFirstTerminusDB"
128-
},
129-
"@type":"terminus:APIUpdate"
130-
}
127+
}
131128

132129
//Create a new Database in the current terminusDB server using the terminusDB server Api key
133130
//dburl is the new Database Id
@@ -236,7 +233,7 @@ client.updateSchema('myFirstTerminusDB',doc,opts).then((response)=>{
236233
##### `createDocument(docurl:String, doc:Object, opts:Object):Promise`
237234
Creates a new document in the specified TerminusDB database
238235

239-
docurl TerminusDB document full URL or a valid TerminusDB document Id or omitted
236+
docurl TerminusDB document full URL or a valid TerminusDB document Id
240237

241238
doc is a document Object
242239

@@ -307,7 +304,7 @@ or
307304
const opts={terminus:encoding: "jsonld",
308305
terminus:user_key: "mykey"}
309306

310-
client.createDocument("http://localhost:6363/myFirstTerminusDB/document/chess/",doc,opts).then((response)=>{
307+
client.createDocument("http://localhost:6363/myFirstTerminusDB/document/chess",doc,opts).then((response)=>{
311308
console.log(response)
312309
}).catch((err)=>{
313310
console.log(err)
@@ -321,7 +318,7 @@ client.createDocument("http://localhost:6363/myFirstTerminusDB/document/chess/",
321318
##### `getDocument(docurl:String, opts:Object):Promise`
322319
Retrieves a document from the specified TerminusDb
323320

324-
docurl TerminusDB document full URL or a valid TerminusDB document Id or omitted
321+
docurl TerminusDB document full URL or a valid TerminusDB document Id
325322

326323
```js
327324

@@ -349,14 +346,100 @@ client.getDocument("doc:chess",opts).then((response)=>{
349346
});
350347

351348

349+
...
350+
351+
```
352+
353+
354+
##### `updateDocument(docurl:String, doc:Object, opts:Object):Promise`
355+
Update the document data in the specified TerminusDB database
356+
357+
docurl TerminusDB document full URL or a valid TerminusDB document Id
358+
359+
doc is a document Object
360+
361+
```js
362+
363+
//Object
364+
const doc={
365+
"rdfs:label":[
366+
{
367+
"@value":"Chess Group",
368+
"@type":"xsd:string"
369+
}
370+
],
371+
"rdfs:comment":[
372+
{
373+
"@value":"this is a group for chess players",
374+
"@type":"xsd:string"
375+
}
376+
],
377+
"tcs:identity":[
378+
{
379+
"tcs:website":[
380+
{
381+
"@value":"www.chessPlayer.com",
382+
"@type":"xdd:url"
383+
}
384+
],
385+
"@type":"tcs:Identifier",
386+
"@id":"_:f89plh1570198207869"
387+
}
388+
],
389+
"@type":"http://terminusdb.com/schema/tcs#Group",
390+
"@context":{
391+
"s":"http://localhost:6363/myFirstTerminusDB/schema#",
392+
"dg":"http://localhost:6363/myFirstTerminusDB/schema",
393+
"doc":"http://localhost:6363/myFirstTerminusDB/document/",
394+
"db":"http://localhost:6363/myFirstTerminusDB/",
395+
"g":"http://localhost:6363/",
396+
"rdf":"http://www.w3.org/1999/02/22-rdf-syntax-ns#",
397+
"rdfs":"http://www.w3.org/2000/01/rdf-schema#",
398+
"xsd":"http://www.w3.org/2001/XMLSchema#",
399+
"owl":"http://www.w3.org/2002/07/owl#",
400+
"tcs":"http://terminusdb.com/schema/tcs#",
401+
"tbs":"http://terminusdb.com/schema/tbs#",
402+
"xdd":"http://terminusdb.com/schema/xdd#",
403+
"terminus":"http://terminusdb.com/schema/terminus#",
404+
"vio":"http://terminusdb.com/schema/vio#",
405+
"docs":"http://terminusdb.com/schema/documentation#",
406+
"scm":"http://localhost:6363/myFirstTerminusDB/schema#",
407+
"_":"http://localhost:6363/myFirstTerminusDB/document/chess/"
408+
}
409+
}
410+
/
411+
// opts.terminus:encoding defines which format is requested (jsonld/frame)
412+
const opts={terminus:encoding: "jsonld"}
413+
414+
client.updateDocument("doc:chess",doc,opts).then((response)=>{
415+
console.log(response)
416+
}).catch((err)=>{
417+
console.log(err)
418+
});
419+
420+
421+
or
422+
423+
//opts.key is an API key
424+
425+
const opts={terminus:encoding: "jsonld",
426+
terminus:user_key: "mykey"}
427+
428+
client.updateDocument("http://localhost:6363/myFirstTerminusDB/document/chess",doc,opts).then((response)=>{
429+
console.log(response)
430+
}).catch((err)=>{
431+
console.log(err)
432+
});
433+
434+
352435
...
353436

354437
```
355438

356439
##### `deleteDocument(docurl:String, opts:Object):Promise`
357440
Delete a document from the specified TerminusDb
358441

359-
docurl TerminusDB document full URL or a valid TerminusDB document Id or omitted
442+
docurl TerminusDB document full URL or a valid TerminusDB document Id
360443

361444
```js
362445
client.deleteDocument("doc:chess",opts).then((response)=>{

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"lint": "eslint --fix lib/**",
5050
"build": "webpack --mode production",
5151
"prepare": "npm run clean && npm run test && npm run build",
52-
"coveralls-after": "nyc report --reporter=text-lcov | coveralls"
52+
"coveralls-after": "nyc report --reporter=text-lcov | coveralls",
53+
"npm:publish": "npm publish --access public"
5354
},
5455
"repository": {
5556
"type": "git",

0 commit comments

Comments
 (0)