UNPKG

codeworld

Version:

A simple Database & Discord.js module.

85 lines (52 loc) β€’ 2.04 kB
<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) ![Join Discord](https://discordapp.com/api/guilds/747036004879302706/widget.png?style=banner2) --- ## πŸ› οΈ License Open source under the MIT license. --- Developed by: **CodeWorld Team** > Got questions? Don’t hesitate to ask! πŸš€