-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (41 loc) · 1.01 KB
/
index.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
53
54
55
const arangojs = require('arangojs');
const db = new arangojs.Database({url:'http://127.0.0.1:8529'});
db.useBasicAuth("root", "Roncodes");
db.useDatabase('crudOps');
//Creating a collection
// db.collection('users').create();
const mainCollection = db.collection('users');
//Adding a user
const addUser = (user) => {
const name = user.name
const task = user.task
mainCollection.save({
name,
task
})
console.log('The user ' + name +' has been created!')
}
// addUser({
// name: "baron",
// task:"jog"
// })
//RemovingUserByKey
const removeUser = (_key) => {
if (_key !== mainCollection._key ) {
return console.log('Please enter valid key')
}
mainCollection.remove(_key)
console.log('User with ' + _key +' has been removed')
}
// removeUser('28458');
//update user
const updateUser = (_key, data) => {
const name = data.name
const task = data.task
mainCollection.update(_key, {name, task}, {
returnNew: true
})
}
// updateUser('27506', {
// task: "finally"
// })