codeworld
Version:
A simple Database & Discord.js module.
85 lines (52 loc) β’ 2.04 kB
Markdown
<div align="center">
<p>
<a href="https://www.npmjs.com/package/codeworld"><img src="https://img.shields.io/npm/v/codeworld.svg?maxAge=3600" alt="npm version" /></a>
<a href="https://www.npmjs.com/package/codeworld"><img src="https://img.shields.io/npm/dt/codeworld.svg?maxAge=3600" alt="npm downloads" /></a>
</p>
</div>
# π¦ 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
```bash
npm install codeworld
```
## π Usage
```js
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](https://discord.gg/pGA9M5UCnt)

## π οΈ License
Open source under the MIT license.
Developed by: **CodeWorld Team**
> Got questions? Donβt hesitate to ask! π