Skip to content

Commit db29eaf

Browse files
authored
Merge pull request #46 from dgraph-io/bucanero/patch-1
Update README.md
2 parents 8af149e + 70a671c commit db29eaf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ use a different version of this client.
6262

6363
| Dgraph version | dgraph-js-http version |
6464
| :------------: | :--------------------: |
65+
| >= 21.03.0 | >= _21.3.0_ |
6566
| >= 20.03.0 | >= _20.3.0_ |
6667
| >= 1.1 | >= _1.1.0_ |
6768

@@ -97,6 +98,41 @@ const dgraphClient = new dgraph.DgraphClient(clientStub);
9798

9899
To facilitate debugging, [debug mode](#debug-mode) can be enabled for a client.
99100

101+
### Multi-tenancy
102+
103+
In [multi-tenancy](https://dgraph.io/docs/enterprise-features/multitenancy) environments, `dgraph-js-http` provides a new method `loginIntoNamespace()`,
104+
which will allow the users to login to a specific namespace.
105+
106+
In order to create a JavaScript client, and make the client login into namespace `123`:
107+
108+
```js
109+
const dgraphClientStub = new dgraph.DgraphClientStub("localhost:9080");
110+
await dgraphClientStub.loginIntoNamespace("groot", "password", 123); // where 123 is the namespaceId
111+
```
112+
113+
In the example above, the client logs into namespace `123` using username `groot` and password `password`.
114+
Once logged in, the client can perform all the operations allowed to the `groot` user of namespace `123`.
115+
116+
### Create a Client for Dgraph Cloud Endpoint
117+
118+
If you want to connect to Dgraph running on your [Dgraph Cloud](https://cloud.dgraph.io) instance, then all you need is the URL of your Dgraph Cloud endpoint and the API key. You can get a client using them as follows:
119+
120+
```js
121+
const dgraph = require("dgraph-js-http");
122+
123+
//here we pass the cloud endpoint
124+
const clientStub = new dgraph.DgraphClientStub(
125+
"https://super-pail.us-west-2.aws.cloud.dgraph.io",
126+
);
127+
128+
const dgraphClient = new dgraph.DgraphClient(clientStub);
129+
130+
//here we pass the API key
131+
dgraphClient.setSlashApiKey("<api-key>");
132+
```
133+
134+
**Note:** the `setSlashApiKey` method is deprecated and will be removed in the next release.
135+
100136
### Login into Dgraph
101137

102138
If your Dgraph server has Access Control Lists enabled (Dgraph v1.1 or above),

0 commit comments

Comments
 (0)