Chapter 7: remove redundant directory
This commit is contained in:
parent
c5506a3f0c
commit
2a91ee2c90
@ -1,26 +0,0 @@
|
||||
const levelup = require("levelup");
|
||||
const memdown = require("memdown");
|
||||
|
||||
const db = levelup(memdown("./data"));
|
||||
|
||||
const task = process.argv[2];
|
||||
|
||||
if (!task) {
|
||||
listTasks();
|
||||
} else {
|
||||
addTask();
|
||||
}
|
||||
|
||||
function addTask() {
|
||||
const key = `Task: ${Math.random().toString(32).replace(".", "")}`;
|
||||
db.put(key, task, (err) => {
|
||||
if (err) throw err;
|
||||
listTasks();
|
||||
});
|
||||
}
|
||||
|
||||
function listTasks() {
|
||||
db.createReadStream().on("data", (data) => {
|
||||
console.log(data.key.toString(), "=", data.value.toString());
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user