File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ Mutation can be run using `txn.doRequest` as well.
187187
188188``` js
189189const mu = new dgraph.Mutation ();
190- mu .setSetJson (q );
190+ mu .setSetJson (p );
191191
192192const req = new dgraph.Request ();
193193req .setCommitNow (true );
@@ -244,7 +244,7 @@ Number of people named "Alice": 1
244244Alice
245245```
246246
247- You can also use ` txn.doQuery ` function to run the query.
247+ You can also use ` txn.doRequest ` function to run the query.
248248``` js
249249const req = new dgraph.Request ();
250250const vars = req .getVarsMap ();
@@ -256,6 +256,13 @@ console.log(JSON.stringify(res.getJson()));
256256```
257257
258258### Running an Upsert: Query + Mutation
259+
260+ The ` txn.doRequest ` function allows you to run upserts consisting of one query and one mutation.
261+ Query variables could be defined and can then be used in the mutation. You can also use the
262+ ` txn.doRequest ` function to perform just a query or a mutation.
263+
264+ To know more about upsert, we highly recommend going through the docs at https://docs.dgraph.io/mutations/#upsert-block .
265+
259266``` js
260267const query = `
261268 query {
@@ -271,7 +278,7 @@ req.setMutationsList([mu]);
271278req .setCommitNow (true );
272279
273280// Update email only if matching uid found.
274- await dgraphClient .newTxn ().doQuery (req);
281+ await dgraphClient .newTxn ().doRequest (req);
275282```
276283
277284### Committing a transaction
You can’t perform that action at this time.
0 commit comments