1.0.2 • Published 4 years ago
lerndb v1.0.2
Hello World
Support: discord.gg/MaapZw5YVC NPM: npmjs.com/package/lerndb
Lerndb is an open-source package meant to provide an easy way for beginners and people of all levels to access & store data in a low to medium volume environment.
- Security - You don't need to be afraid as it is open source.
- Execute - No need to set up a database server, all the data is stored locally in the same project.
Easy - Originally created for use in tutorials, the documentation is straightforward and jargon-free.
Installation
It goes down to all operating systems, linux, windows, mac doesn't matter, but nodejs version should be at least 12x
npm install lerndb
Demo Documentation
const { Database } = require("lerndb");
const db = new Database({ open: "./database.json" });
Examples
// Setting an object in the database:
db.set('userInfo', 'id')
// Pushing an element to an array (that doesn't exist yet) in an object:
db.push('userInfo.items', 'apple')
// Adding to a number (that doesn't exist yet) in an object:
db.add('userInfo.balance', 500)
// Data fetch
db.get('userInfo.balance')
db.get('userInfo.items')
db.fetch('userInfo')
Methods
.add(key, number, [options]) -> updatedRow
.all() -> array
.delete(key, [options]) -> boolean
.get(key, [options]) -> row
.has(key, [options]) -> boolean
.push(key, element, [options]) -> updatedRow
.set(key, data, [options]) -> updatedRow
.subtract(key, number, [options]) -> updatedRow
.includes(key) -> finding
.startsWith(key) -> finding