DoodleDB is a lightweight package that allows you to utilize JSON files as databases
To install DoodleDB, run the following command:
npm install doodledb
- Import the class into your Node.js application
import { DoodleDB } from "doodledb";
- Instantiate the class with the path to the JSON file
const database = new DoodleDB({ filePath: "database.json" });
- Use DoodleDB's many functions to manipulate the database!
For detailed documentation of every method on the DoodleDB class, visit our GitHub Docs Page
Add new data to the JSON file
database.push({ filePath, collectionName, data })
.then((successMessage) => {
console.log(successMessage);
})
.catch((error) => {
console.error(error);
});
Retrieve data from the JSON file based on search criteria.
database.get({ filePath, collectionName, searchQuery: data })
.then((foundData) => {
console.log(foundData);
})
.catch((error) => {
console.error(error);
});
Retrieve an entire collection from the JSON file
database.getCollection({ filePath, collectionName })
.then((dataCollection) => {
console.log(dataCollection);
})
.catch((error) => {
console.error(error);
});
Delete an entire collection from the JSON file
database.deleteCollection({ filePath, collectionName, targetID })
.then((successMessage) => {
console.log(successMessage);
})
.catch((error) => {
console.error(error);
});
Delete specific fields from a data entry in the JSON file
database.delete({ filePath, collectionName, targetID, deleteObject })
.then((successMessage) => {
console.log(successMessage);
})
.catch((error) => {
console.error(error);
});
Create an index for faster searching.
database.createIndex({ filePath, collectionName, fieldName })
.then((successMessage) => {
console.log(successMessage);
})
.catch((error) => {
console.error(error);
});
What are IDs?
Each object within a collection has an ID value. This value increases depending on its order in the array. If it is at position one, the ID will be 1.- Join the Discord Server server for support -
This project is under the MIT license. Read more about this license at LICENSE