Skip to content

Commit 978a6c3

Browse files
committed
chore: refactored examples, added failsafe erro check in lib/client and updated lib files
1 parent 49dd938 commit 978a6c3

File tree

8 files changed

+234
-813
lines changed

8 files changed

+234
-813
lines changed

examples/auth-management.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ async function main(err, cl) {
1818
let res = await cl.login(req)
1919

2020
res = await cl.useDatabase({ database: 'defaultdb' })
21+
22+
console.log('useDatabase successfull, token:', res && res.token)
2123

2224
await cl.updateAuthConfig({ auth: types.auth.enabled })
2325

26+
console.log('updateAuthConfig')
27+
2428
await cl.updateMTLSConfig({ enabled: false })
2529

30+
console.log('updateMTLSConfig')
31+
2632
} catch (err) {
2733
console.log(err)
2834
}
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async function main(err, cl) {
2020

2121
res = await cl.useDatabase({ database: 'defaultdb' })
2222

23+
// set batch ops
2324
for (let i = 0; i < 20; i++) {
2425
req = {
2526
kvList : [
@@ -28,18 +29,18 @@ async function main(err, cl) {
2829
}
2930
res = await cl.setBatch(req)
3031
console.log(res)
31-
32-
req = {
33-
skvList: [{
34-
key: i+20,
35-
payload: i+20,
36-
timestamp: unix,
37-
}]
38-
}
39-
res = await cl.setBatchSV(req)
40-
console.log(res)
4132
}
4233

34+
// get batch ops
35+
for (let i = 0; i < 20; i++) {
36+
req = {
37+
kvList : [
38+
{ key: i },
39+
]
40+
}
41+
res = await cl.getBatch(req)
42+
console.log(res)
43+
}
4344
} catch (err) {
4445
console.log(err)
4546
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const ImmudbClient = require('../lib/client')
22
const root = require('../lib/root')
33

44
ImmudbClient({
5-
address: '127.0.0.1:3322',
5+
address: '127.0.0.1:56789',
6+
rootPath: 'rootfile'
67
}, main)
78

89
const rand = '' + Math.floor(Math.random()
@@ -17,6 +18,8 @@ async function main(err, cl) {
1718
let req = { username: 'immudb', password: 'immudb' }
1819
let res = await cl.login(req)
1920

21+
console.log(rand);
22+
2023
await cl.createDatabase({ database: rand })
2124

2225
res = await cl.useDatabase({ database: rand })

examples/database-ops-structured.js

Lines changed: 0 additions & 119 deletions
This file was deleted.

examples/user-management.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ async function main(err, cl) {
1818
try {
1919
let req = { username: 'immudb', password: 'immudb' }
2020
let res = await cl.login(req)
21-
console.log(res)
21+
22+
console.log('login successfull, token:', res && res.token)
2223

2324
req = {
2425
username: rand,
@@ -28,6 +29,8 @@ async function main(err, cl) {
2829
}
2930
await cl.createUser(req)
3031

32+
console.log('createUser successfull: ', res)
33+
3134
res = await cl.listUsers()
3235
console.log(util.inspect(res, false, 6, true))
3336

0 commit comments

Comments
 (0)