codeWorld/db is a simple and modular JSON database system. It works with a key-value structure and stores data in the filesystem using JSON format.
✅ Local data storage, quick setup, zero dependencies!
npm install codeworld
const db = require("codeworld/db")
// SET
db.set("x.y.z", "abc") // "abc"
// GET
db.get("x") // { y: { z: "abc" } }
// FETCH (alias of get)
db.fetch("x") // { y: { z: "abc" } }
// DELETE
db.delete("x") // true
// PUSH (adds to an array)
db.push("my.list", "item") // ["item"]
// UNPUSH (removes from an array)
db.unpush("my.list", "item") // true
// ALL (flattens and returns all records)
db.all() // { "x.y.z": "abc", "my.list": ["item"] }
// ALL + FILTER example
const filtered = Object.entries(db.all()).filter(([key, val]) => key.startsWith("x."));
All functions include validation checks such as:
- Missing key:
throw new Error('Key is required.')
- Missing value:
throw new Error('Value is required.')
- Unknown function access:
Function 'xyz' not found.
Have questions, feedback, or want to contribute? Join our Discord server:
Open source under the MIT license.
Developed by: CodeWorld Team
Got questions? Don’t hesitate to ask! 🚀