-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.js
38 lines (36 loc) · 1 KB
/
run.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
// import service functions file
const notes = require('./services/notes');
// run mongoDB calls
async function run(method, data) {
try {
if(method === 'create') {
const res = await notes.addNote(data);
return res;
}
else if(method === 'read_all') {
const res = await notes.readNotes();
return res;
}
else if(method === 'read_one') {
const res = await notes.readNote(data);
return res;
}
else if(method === 'update_one') {
const res = await notes.updateNote(data);
return res;
}
else if(method === 'sync_note') {
const res = await notes.syncNote(data);
return res;
}
else if(method === 'delete_note') {
const res = await notes.softDeleteNote(data);
return res;
}
else return 'invalid command';
} catch (e) {
console.log('error:', e.message);
return false;
}
};
module.exports = run;