Skip to content

Commit 9914619

Browse files
authored
Merge pull request #4 from zaidajani/master
Update db.js
2 parents 18ad104 + 31e5420 commit 9914619

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: db.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const fs = require('fs');
22
let db = {};
33
updateDbVariable();
44

5+
// function initialize
6+
57
function initialize() {
68
try {
79
fs.readFileSync('database.dbs', 'utf-8');
@@ -16,6 +18,8 @@ function initialize() {
1618
}
1719
}
1820

21+
// refresher
22+
1923
function updateDbVariable() {
2024
try {
2125
db = JSON.parse(fs.readFileSync('database.dbs', 'utf-8'));
@@ -24,6 +28,8 @@ function updateDbVariable() {
2428
}
2529
}
2630

31+
// refresher
32+
2733
function updateDb(data) {
2834
try {
2935
fs.writeFileSync('database.dbs', JSON.stringify(data));
@@ -32,6 +38,8 @@ function updateDb(data) {
3238
}
3339
}
3440

41+
// usable functions
42+
3543
function add(key, value) {
3644
db[key] = value;
3745
updateDb(db);
@@ -53,10 +61,12 @@ function readAllData() {
5361
return db;
5462
}
5563

64+
// exports
65+
5666
module.exports = {
5767
initialize,
5868
add,
5969
get,
6070
vanish,
6171
readAllData
62-
}
72+
}

0 commit comments

Comments
 (0)