-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
67 lines (58 loc) · 1.69 KB
/
db.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
56
57
58
59
60
61
62
63
64
65
66
67
const Loki = require('lokijs');
const db = new Loki('loki.db',{
autoload: true,
autoloadCallback : databaseInitialize,
autosave: true,
autosaveInterval: 4000
});
let kanbanCollection ;
// implement the autoloadback referenced in loki constructor
function databaseInitialize() {
let kanban = db.getCollection("kanban");
let shortUrl = db.getCollection("shortUrl");
if (kanban === null) {
console.log("new kanban");
kanban = db.addCollection("kanban", {unique: ['name'] });
}
if (shortUrl === null) {
console.log("new shortUrl");
shortUrl = db.addCollection("shortUrl");
}
// kick off any program logic or start listening to external events
runProgramLogic();
}
// example method with any bootstrap logic to run after database initialized
function runProgramLogic() {
var entryCount = db.getCollection("kanban").count();
console.log("number of kanban entries in database : " + entryCount);
kanbanCollection=db.getCollection("kanban");
}
function readCollection(name){
return db.getCollection(name);
}
let kanbanStrcu ={
"id":"string",
"name":"string",
"total":"string",
"shortUrl62hex":"string",
"user":"string",
"isPublic":"Boolean",
"item":[{
"itemName": "string",
"unit": "string",
"number": "",
"startDateTime": "",
"endDateTime": "",
"perUpdateNumber": "string"
}],
};
let shortUrlStrcu ={
"id":"number",
"shortUrl62hex":"string",
"originalUrl":"string",
"user":"string",
"isPublic":"Boolean"
};
module.exports={
database:db
} ;