1
- # dgraph-js [ ![ npm version] ( https://img.shields.io/npm/v/dgraph-js.svg?style=flat )] ( https://www.npmjs.com/package/dgraph-js ) [ ![ Build Status ] ( https://teamcity.dgraph.io/guestAuth/app/rest/builds/buildType:(id:dgraphjs_Build)/statusIcon.svg )] ( https://teamcity.dgraph.io/viewLog.html?buildTypeId=dgraphjs_Build&buildId=lastFinished&guest=1 ) [ ![ Coverage Status] ( https://img.shields.io/coveralls/github/dgraph-io/dgraph-js/master.svg?style=flat )] ( https://coveralls.io/github/dgraph-io/dgraph-js?branch=master )
1
+ # dgraph-js [ ![ npm version] ( https://img.shields.io/npm/v/dgraph-js.svg?style=flat )] ( https://www.npmjs.com/package/dgraph-js ) [ ![ Coverage Status] ( https://img.shields.io/coveralls/github/dgraph-io/dgraph-js/master.svg?style=flat )] ( https://coveralls.io/github/dgraph-io/dgraph-js?branch=master )
2
2
3
3
Official Dgraph client implementation for JavaScript (Node.js v6 and above),
4
4
using [ gRPC] .
5
5
6
- ** Use [ Discuss Issues] ( https://discuss.dgraph.io/c/issues/35/clients/46 ) for reporting issues about this repository.**
7
-
8
6
** Looking for browser support? Check out [ dgraph-js-http] .**
9
7
10
8
[ grpc ] : https://grpc.io/
@@ -14,18 +12,23 @@ This client follows the [Dgraph Go client][goclient] closely.
14
12
15
13
[ goclient ] : https://github.com/dgraph-io/dgo
16
14
17
- Before using this client, we highly recommend that you go through [ docs. dgraph.io] ,
15
+ Before using this client, we highly recommend that you go through [ dgraph.io/docs ] ,
18
16
and understand how to run and work with Dgraph.
19
17
20
- [ docs.dgraph.io ] :https://docs.dgraph.io
18
+ [ docs.dgraph.io ] :https://dgraph.io/docs
19
+
21
20
22
21
## Table of contents
23
22
23
+ - [ dgraph-js ] ( #dgraph-js-- )
24
+ - [ Table of contents] ( #table-of-contents )
24
25
- [ Install] ( #install )
25
26
- [ Supported Versions] ( #supported-versions )
26
27
- [ Quickstart] ( #quickstart )
27
28
- [ Using a Client] ( #using-a-client )
28
29
- [ Creating a Client] ( #creating-a-client )
30
+ - [ Multi-tenancy] ( #multi-tenancy )
31
+ - [ Creating a Client for Dgraph Cloud Endpoint] ( #creating-a-client-for-dgraph-cloud-endpoint )
29
32
- [ Altering the Database] ( #altering-the-database )
30
33
- [ Creating a Transaction] ( #creating-a-transaction )
31
34
- [ Running a Mutation] ( #running-a-mutation )
@@ -66,15 +69,11 @@ use a different version of this client.
66
69
67
70
| Dgraph version | dgraph-js version |
68
71
| :--------------:| :-----------------:|
69
- | 1.0.X | * 1.X.Y* |
70
- | 1.1.X | * 2.X.Y* |
71
72
| 20.03.0 | * 20.03.0* |
72
73
| 21.03.0 | * 21.03.0* |
73
- | >=21.03.0 | >=* 21.03.0* |
74
+ | >=21.03.0 | >=* 21.03.0* |
75
+ | >=24.X.X | >=* 24.X.X* |
74
76
75
- Note: Only API breakage from * v1.X.Y* to * v2.X.Y* is in
76
- the function ` DgraphClient.newTxn().mutate() ` . This function returns a ` messages.Assigned `
77
- type in * v1.X* but a ` messages.Response ` type in * v2.X* .
78
77
79
78
## Quickstart
80
79
@@ -116,7 +115,7 @@ In order to create a JavaScript client, and make the client login into namespace
116
115
117
116
``` js
118
117
const dgraphClientStub = new dgraph.DgraphClientStub (" localhost:9080" );
119
- await dgraphClientStub .loginIntoNamespace (" groot" , " password" , 123 ); // where 123 is the namespaceId
118
+ await dgraphClientStub .loginIntoNamespace (" groot" , " password" , 123 ); // where 123 is the namespaceId
120
119
```
121
120
122
121
In the example above, the client logs into namespace ` 123 ` using username ` groot ` and password ` password ` .
@@ -166,7 +165,7 @@ await dgraphClient.alter(op);
166
165
> NOTE: Many of the examples here use the ` await ` keyword which requires
167
166
> ` async/await ` support which is available on Node.js >= v7.6.0. For prior versions,
168
167
> the expressions following ` await ` can be used just like normal ` Promise ` :
169
- >
168
+ >
170
169
> ``` js
171
170
> dgraphClient .alter (op)
172
171
> .then (function (result ) { ... }, function (err ) { ... })
@@ -328,8 +327,8 @@ console.log(JSON.stringify(res.getJson()));
328
327
329
328
### Running an Upsert: Query + Mutation
330
329
331
- The ` txn.doRequest ` function allows you to run upserts consisting of one query and one mutation.
332
- Query variables could be defined and can then be used in the mutation. You can also use the
330
+ The ` txn.doRequest ` function allows you to run upserts consisting of one query and one mutation.
331
+ Query variables could be defined and can then be used in the mutation. You can also use the
333
332
` txn.doRequest ` function to perform just a query or a mutation.
334
333
335
334
To know more about upsert, we highly recommend going through the docs at https://docs.dgraph.io/mutations/#upsert-block .
0 commit comments