Uh oh!
There was an error while loading. Please reload this page.
forked from learneradarsh/CodeRepo
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnehandler.js
More file actions
Latest commit
66 lines (50 loc) · 1.33 KB
/
Copy pathnehandler.js
File metadata and controls
66 lines (50 loc) · 1.33 KB
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
56
57
58
59
60
61
62
63
64
65
66
constDatastore=require('nedb');
const{app}=require('electron');
constuserData=app.getAppPath('userData').replace('/app.asar','');
constsnips=newDatastore({filename: userData+'/db/snips.db',autoload: true});
functioninsertSnip(snip,done){
snips.insert(snip,function(err,result){
done(result.ops);
})
}
functionsearchSnip(title,done){
snips.find({
"title": newRegExp(title)
}).sort({"language": 1}).exec(
function(err,result){
done(result);
})
}
functionfindSnip(snipId,done){
snips.findOne({
// _id: ObjectId(snipId.toString())
_id: snipId
},function(err,result){
done(result);
})
}
functionallSnips(done){
snips.find({}).sort({"language": 1}).exec(function(err,result){
done(result)
})
}
functionupdateSnip(snipId,snip,done){
snips.find({}).exec(function(err,result){
snips.update({
// _id: ObjectId(snipId.toString())
_id: snipId
},snip,function(err,result){
done(result);
})
})
}
functiondeleteSnip(snipId,done){
snips.remove({
_id: snipId
},function(err,result){
done(result);
})
}
module.exports={
insertSnip, findSnip, allSnips, updateSnip, deleteSnip, searchSnip
};