Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.

Commit 31aa883

Browse files
committed
Fixed wierd README and moved documentation to Txn
1 parent a730822 commit 31aa883

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ and understand how to run and work with Dgraph.
1414

1515
## Table of contents
1616

17-
- [dgraph-js-http <img src="https://img.shields.io/npm/v/dgraph-js-http.svg?style=flat" alt="npm version"> <img src="https://img.shields.io/travis/dgraph-io/dgraph-js-http/master.svg?style=flat" alt="Build Status"> <img src="https://img.shields.io/coveralls/github/dgraph-io/dgraph-js-http/master.svg?style=flat" alt="Coverage Status">](#dgraph-js-http-img-src%22httpsimgshieldsionpmvdgraph-js-httpsvgstyleflat%22-alt%22npm-version%22-img-src%22httpsimgshieldsiotravisdgraph-iodgraph-js-httpmastersvgstyleflat%22-alt%22build-status%22-img-src%22httpsimgshieldsiocoverallsgithubdgraph-iodgraph-js-httpmastersvgstyleflat%22-alt%22coverage-status%22)
18-
- [Table of contents](#table-of-contents)
1917
- [Install](#install)
2018
- [Quickstart](#quickstart)
2119
- [Using a client](#using-a-client)
@@ -151,6 +149,16 @@ try {
151149
}
152150
```
153151

152+
You can make queries read-only and best effort by passing ```options``` to ```DgraphClient#newTxn```. For example:
153+
154+
```js
155+
const options = { readOnly: true, bestEffort: true };
156+
const res = await dgraphClient.newTxn(options).query(query);
157+
```
158+
159+
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.
160+
161+
154162
### Run a mutation
155163

156164
`Txn#mutate(Mutation)` runs a mutation. It takes in a `Mutation` object, which
@@ -185,6 +193,7 @@ mutation must be immediately committed.
185193
await txn.mutate({ setJson: p, commitNow: true });
186194
```
187195

196+
188197
### Run a query
189198

190199
You can run a query by calling `Txn#query(string)`. You will need to pass in a
@@ -232,14 +241,6 @@ Number of people named "Alice": 1
232241
Alice
233242
```
234243

235-
Read-only and best effort queries can be called by passing ```options``` to ```Txn.query``` and ```Txn.queryWithVars```. For example:
236-
237-
```js
238-
const options = { readOnly: true, bestEffort: true };
239-
const res = await dgraphClient.newTxn().query(query, options);
240-
```
241-
242-
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.
243244

244245
### Commit a transaction
245246

0 commit comments

Comments
 (0)