Skip to content

Commit 51020a3

Browse files
Updating docs and dgraph-js versions in examples (#116)
Signed-off-by: Prashant Shahi <[email protected]>
1 parent 88eb4fe commit 51020a3

File tree

7 files changed

+25
-8
lines changed

7 files changed

+25
-8
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,23 @@ try {
169169
}
170170
```
171171

172+
To create a read-only transaction, set `readOnly` boolean to `true` while calling
173+
`DgraphClient#newTxn()` method. Read-only transactions cannot contain mutations and
174+
trying to call `Txn#mutate()` or `Txn#commit()` will result in an error. Calling
175+
`Txn.Discard()` will be a no-op.
176+
177+
You can optionally set the `bestEffort` boolean to `true`. This may yield improved
178+
latencies in read-bound workloads where linearizable reads are not strictly needed.
179+
180+
```js
181+
const txn = dgraphClient.newTxn({
182+
readOnly: true,
183+
bestEffort: false
184+
});
185+
// ...
186+
const res = await txn.queryWithVars(query, vars);
187+
```
188+
172189
### Running a Mutation
173190

174191
`Txn#mutate(Mutation)` runs a mutation. It takes in a `Mutation` object, which

examples/simple/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ for Dgraph.
99

1010
### Start Dgraph server
1111

12-
You will need to install [Dgraph v1.1.0 or above][releases] and run it.
12+
You will need to install [Dgraph v20.03.0 or above][releases] and run it.
1313

1414
[releases]: https://github.com/dgraph-io/dgraph/releases
1515

examples/simple/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async function queryData(dgraphClient) {
110110
}
111111
}`;
112112
const vars = { $a: "Alice" };
113-
const res = await dgraphClient.newTxn().queryWithVars(query, vars);
113+
const res = await dgraphClient.newTxn({ readOnly: true }).queryWithVars(query, vars);
114114
const ppl = res.getJson();
115115

116116
// Print results.

examples/simple/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "simple",
33
"dependencies": {
4-
"dgraph-js": "^2.1.0",
5-
"grpc": "^1.23.3"
4+
"dgraph-js": "^20.3.0",
5+
"grpc": "^1.24.2"
66
}
77
}

examples/tls/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cluster (1 Dgraph Zero and 1 Dgraph Alpha) configured with mutual TLS.
1010

1111
### Install Dgraph
1212

13-
You will need to [install Dgraph v1.1.0 or
13+
You will need to [install Dgraph v20.03.0 or
1414
above](https://github.com/dgraph-io/dgraph/releases) and run it.
1515

1616
A quick-start installation script is available for Linux and Mac:

examples/tls/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async function queryData(dgraphClient) {
122122
}
123123
}`;
124124
const vars = { $a: "Alice" };
125-
const res = await dgraphClient.newTxn().queryWithVars(query, vars);
125+
const res = await dgraphClient.newTxn({ readOnly: true }).queryWithVars(query, vars);
126126
const ppl = res.getJson();
127127

128128
// Print results.

examples/tls/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tls",
33
"dependencies": {
4-
"dgraph-js": "^2.1.0",
5-
"grpc": "^1.23.3"
4+
"dgraph-js": "^20.3.0",
5+
"grpc": "^1.24.2"
66
}
77
}

0 commit comments

Comments
 (0)