You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 5, 2025. It is now read-only.
To set the schema, pass the schema to `DgraphClient#alter(Operation)` method.
@@ -180,15 +200,15 @@ and you can call `Txn#discard()` multiple times with no additional side-effects.
180
200
```js
181
201
consttxn=dgraphClient.newTxn();
182
202
try {
183
-
// Do something here
184
-
// ...
203
+
// Do something here
204
+
// ...
185
205
} finally {
186
-
awaittxn.discard();
187
-
// ...
206
+
awaittxn.discard();
207
+
// ...
188
208
}
189
209
```
190
210
191
-
You can make queries read-only and best effort by passing ```options``` to ```DgraphClient#newTxn```. For example:
211
+
You can make queries read-only and best effort by passing `options` to `DgraphClient#newTxn`. For example:
192
212
193
213
```js
194
214
constoptions= { readOnly:true, bestEffort:true };
@@ -197,7 +217,6 @@ const res = await dgraphClient.newTxn(options).query(query);
197
217
198
218
Read-only transactions are useful to increase read speed because they can circumvent the usual consensus protocol. Best effort queries can also increase read speed in read bound system. Please note that best effort requires readonly.
199
219
200
-
201
220
### Run a mutation
202
221
203
222
`Txn#mutate(Mutation)` runs a mutation. It takes in a `Mutation` object, which
@@ -232,7 +251,6 @@ mutation must be immediately committed.
232
251
awaittxn.mutate({ setJson: p, commitNow:true });
233
252
```
234
253
235
-
236
254
### Run a query
237
255
238
256
You can run a query by calling `Txn#query(string)`. You will need to pass in a
@@ -243,7 +261,7 @@ the variables object as the second argument.
243
261
The response would contain the `data` field, `Response#data`, which returns the response
244
262
JSON.
245
263
246
-
Let’s run the following query with a variable $a:
264
+
Let’s run the following query with a variable \$a:
247
265
248
266
```console
249
267
query all($a: string) {
@@ -270,7 +288,7 @@ const ppl = res.data;
270
288
271
289
// Print results.
272
290
console.log(`Number of people named "Alice": ${ppl.all.length}`);
0 commit comments