codeworld

1.0.6 • Public • Published

npm version npm downloads

📦 CodeWorld

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!


🔗 Installation

npm install codeworld

🚀 Usage

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."));

⚠️ Error Handling

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.

💬 Support / Community

Have questions, feedback, or want to contribute? Join our Discord server:

👉 Join Discord

Join Discord


🛠️ License

Open source under the MIT license.


Developed by: CodeWorld Team

Got questions? Don’t hesitate to ask! 🚀

Package Sidebar

Install

npm i codeworld

Weekly Downloads

40

Version

1.0.6

License

ISC

Unpacked Size

8.96 kB

Total Files

13

Last publish

Collaborators

  • moonoffical