[ TBD ] - Documentation isn't yet ready fully but here's a few examples:
const Josh = require("@joshdb/core");const provider = require('@joshdb/sqlite');const db = new Josh({name: 'testing',provider,});// this is an "IIFE", immediately invoked function expression.(async () => {// 'count' gives you the size/count/number of rows.console.log(`Connected, there are ${await db.size} rows in the database.`);// SETTING DATA// Supports simple stringsawait db.set("somestring", "This is a simple string value");// Supports arraysawait db.set("anarray", [ 1, 2, 3, 4, 5 ]);// Supports arrays of objectsawait db.set("arrofobj", [ { a: 1, b: 2 }, { c: 3, d: 4 } ]);// Supports objects (obviously, the name is a dead giveaway!)await db.set("object", { id: 123345, name: "Josh Grow Ban", description: "Some dude" });// Supports setting object properties using pathsawait db.set("object.description", "A most awesome dude");// Supports setting things in arrays by indexawait db.set("anarray.0", "one"); // [ 'one', 2, 3, 4, 5 ]// GETTING DATAawait db.get("somestring"); // the string aboveawait db.get("anarray"); // ditto on the arrayawait db.get("anarray.0"); // supports paths and indexes, returns 'one' in this caseawait db.get("object.name"); // supports paths in objects of course.// DELETINGawait db.delete(db.all); // CLEARS THE ENTIRE DATABASEawait db.delete("string"); // deletes one keyawait db.delete("object.description"); // deletes one object property by pathawait db.delete("arrayofobj.1"); // deletes one array element by index})();