Skip to content

Commit 83621ba

Browse files
authored
Merge pull request #137 from dgraph-io/bucanero/patch-1
Update README.md
2 parents 1743fb3 + ccc513f commit 83621ba

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ use a different version of this client.
6969
| 1.0.X | *1.X.Y* |
7070
| 1.1.X | *2.X.Y* |
7171
| 20.03.0 | *20.03.0* |
72+
| 21.03.0 | *21.03.0* |
7273

7374
Note: Only API breakage from *v1.X.Y* to *v2.X.Y* is in
7475
the function `DgraphClient.newTxn().mutate()`. This function returns a `messages.Assigned`
@@ -105,6 +106,37 @@ const dgraphClient = new dgraph.DgraphClient(clientStub);
105106

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

109+
### Multi-tenancy
110+
111+
In [multi-tenancy](https://dgraph.io/docs/enterprise-features/multitenancy) environments, `dgraph-js` provides a new method `loginIntoNamespace()`,
112+
which will allow the users to login to a specific namespace.
113+
114+
In order to create a JavaScript client, and make the client login into namespace `123`:
115+
116+
```js
117+
const dgraphClientStub = new dgraph.DgraphClientStub("localhost:9080");
118+
await dgraphClientStub.loginIntoNamespace("groot", "password", 123); // where 123 is the namespaceId
119+
```
120+
121+
In the example above, the client logs into namespace `123` using username `groot` and password `password`.
122+
Once logged in, the client can perform all the operations allowed to the `groot` user of namespace `123`.
123+
124+
### Creating a Client for Dgraph Cloud Endpoint
125+
126+
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:
127+
128+
```js
129+
const dgraph = require("dgraph-js");
130+
131+
const clientStub = dgraph.clientStubFromSlashGraphQLEndpoint(
132+
"https://frozen-mango.eu-central-1.aws.cloud.dgraph.io/graphql",
133+
"<api-key>"
134+
);
135+
const dgraphClient = new dgraph.DgraphClient(clientStub);
136+
```
137+
138+
**Note:** the `clientStubFromSlashGraphQLEndpoint` method is deprecated and will be removed in the next release.
139+
108140
### Altering the Database
109141

110142
To set the schema, create an `Operation` object, set the schema and pass it to

0 commit comments

Comments
 (0)