-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (45 loc) · 1.15 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
let { LocalStore } = require("./data_store/store");
let database;
checkRead = () => {
const key = "6";
const obj = database.readElement(key);
if (obj.errMessage.message.length) {
console.log(obj.errMessage.message);
} else {
console.log(obj.data);
}
};
checkCreate = () => {
const key = "5";
const value = {
name: "mikasa",
roll_number: "45645",
};
const timeToLive = 10;
let obj = database.createElement(key, value, timeToLive);
if (obj.errMessage.message.length) {
console.log(obj.errMessage.message);
console.log(obj.errMessage.systemMessage);
} else {
console.log("Element created successfully");
}
};
checkDelete = () => {
const key = "6";
const obj = database.deleteElement(key);
if (obj.errMessage.message.length) {
console.log(obj.errMessage.message);
console.log(obj.errMessage.systemMessage);
} else {
console.log("Element deleted successfully");
}
};
initialFunction = () => {
const newFilePath = "./data_store/db.json";
database = new LocalStore(newFilePath);
// database = new LocalStore();
// checkCreate();
// checkRead();
// checkDelete();
};
initialFunction();