diff options
| author | Leo Goetz <dev@leogtz.de> | 2025-11-08 18:55:03 +0100 |
|---|---|---|
| committer | Leo Goetz <dev@leogtz.de> | 2025-11-08 18:55:03 +0100 |
| commit | 16a0e9a9d2c24af28142ed3420ef6cb373c454f7 (patch) | |
| tree | b948472cea12b505ae3f2cc04b66801207ebc6aa /src/db.js | |
| parent | 91a6ac10e416dcf2c29b6e37e3dfe19672eb0f84 (diff) | |
started making the command and json db
Diffstat (limited to 'src/db.js')
| -rw-r--r-- | src/db.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/db.js b/src/db.js new file mode 100644 index 0000000..39fdc29 --- /dev/null +++ b/src/db.js @@ -0,0 +1,17 @@ +import fs from "node:fs/promises"; + +const DB_PATH = new URL("../db.json", import.meta.url).pathname; + +export const getDB = async () => { + const db = await fs.readFile(DB_PATH, "utf-8"); + return JSON.parse(db); +}; + +export const saveDB = async (db) => { + await fs.writeFile(DB_PATH, JSON.stringify(db, null, 2)); + return db; +}; + +export const insertDB = async (note) => { + const db = await getDB(); +}; |
