snowbase 6.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/bin/snowbase.js +27 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,6 +78,11 @@ const db = new Snowbase();
|
|
|
78
78
|
db.on("ready", () => {
|
|
79
79
|
console.log("Database is ready");
|
|
80
80
|
});
|
|
81
|
+
|
|
82
|
+
//Multiples database
|
|
83
|
+
const db1 = new Snowbase({ baseDir: "storage" });
|
|
84
|
+
const db2 = new Snowbase({ baseDir: "database" }); // creates an isolated new Snowbase storage
|
|
85
|
+
// You need to specify the baseDir if use the CLI
|
|
81
86
|
```
|
|
82
87
|
|
|
83
88
|
### Basic operations
|
package/bin/snowbase.js
CHANGED
|
@@ -55,6 +55,14 @@ ${chalk.bold("SNOWBASE COMMANDS")}
|
|
|
55
55
|
|
|
56
56
|
${chalk.blue("clear")} Clear the database file
|
|
57
57
|
|
|
58
|
+
${chalk.blue("get")} Get the value of a key
|
|
59
|
+
|
|
60
|
+
${chalk.blue("set")} Set the value of a key
|
|
61
|
+
|
|
62
|
+
${chalk.blue("remove")} Remove a key from the database
|
|
63
|
+
|
|
64
|
+
${chalk.blue("has")} Check if a key exists in the database
|
|
65
|
+
|
|
58
66
|
============================================================
|
|
59
67
|
${chalk.bold("COMPILER OPTION")}
|
|
60
68
|
|
|
@@ -77,7 +85,17 @@ if (!cmd) {
|
|
|
77
85
|
console.log(helpMessage);
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
const commands = [
|
|
88
|
+
const commands = [
|
|
89
|
+
"init",
|
|
90
|
+
"inspect",
|
|
91
|
+
"backup",
|
|
92
|
+
"restore",
|
|
93
|
+
"clear",
|
|
94
|
+
"get",
|
|
95
|
+
"set",
|
|
96
|
+
"remove",
|
|
97
|
+
"has",
|
|
98
|
+
];
|
|
81
99
|
if (cmd) {
|
|
82
100
|
let config = {
|
|
83
101
|
baseDir: "./snowbase",
|
|
@@ -207,10 +225,14 @@ if (cmd) {
|
|
|
207
225
|
} else
|
|
208
226
|
console.log(
|
|
209
227
|
chalk.red("Decryption failed, please provide a valid secret"),
|
|
210
|
-
|
|
228
|
+
"Example: snowbase restore --secret <secret> --restoreFile <backup-ID>",
|
|
211
229
|
);
|
|
212
230
|
} else {
|
|
213
|
-
console.log(
|
|
231
|
+
console.log(
|
|
232
|
+
chalk.red(
|
|
233
|
+
`Backup file ${backupFile} does not exist. Check the backup ID or if the dir exists`,
|
|
234
|
+
),
|
|
235
|
+
);
|
|
214
236
|
}
|
|
215
237
|
break;
|
|
216
238
|
}
|
|
@@ -276,12 +298,14 @@ if (cmd) {
|
|
|
276
298
|
else console.log(db.get(config.key));
|
|
277
299
|
break;
|
|
278
300
|
}
|
|
301
|
+
|
|
279
302
|
case "remove": {
|
|
280
303
|
let run = db.remove(config.key);
|
|
281
304
|
if (run) console.log(chalk.green("Value removed successfully"));
|
|
282
305
|
else console.log(chalk.red("Value not removed"));
|
|
283
306
|
break;
|
|
284
307
|
}
|
|
308
|
+
|
|
285
309
|
case "has": {
|
|
286
310
|
let run = db.has(config.key);
|
|
287
311
|
console.log(run);
|