-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite.js
53 lines (32 loc) · 907 Bytes
/
write.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const Aerospike = require('aerospike')
let client = Aerospike.client({
hosts: [
{ addr: "localhost", port:3000 },
],
log: {
level: Aerospike.log.INFO
}
})
client.connect(function (error) {
if (error) {
// handle failure
console.log('Connection to Aerospike cluster failed!')
} else {
// handle success
const key = new Aerospike.Key('test', 'books', '1000')
// Record to be written to the database
let bins = {
uid: 1000,
name: 'Ryan Holiday',
book: "Ego is the Enemy",
}
client.put(key, bins, function (error) {
if (error) {
console.log('error: %s', error.message)
} else {
console.log('Record written to database successfully.')
}
client.close()
})
}
})