doodledb
v3.0.2
Published
DoodleDB is a lightweight package that allows you to utilize JSON files as databases
Downloads
3
Maintainers
Readme
DoodleDB
DoodleDB is a lightweight package that allows you to utilize JSON files as databases
Table of Contents:
Installation
To install DoodleDB, run the following command:
npm install doodledb
Usage
- 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!
Functions
For detailed documentation of every method on the DoodleDB class, visit our GitHub Docs Page
Examples
push
Add new data to the JSON file
database.push({ filePath, collectionName, data })
.then((successMessage) => {
console.log(successMessage);
})
.catch((error) => {
console.error(error);
});
get
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);
});
getCollection
Retrieve an entire collection from the JSON file
database.getCollection({ filePath, collectionName })
.then((dataCollection) => {
console.log(dataCollection);
})
.catch((error) => {
console.error(error);
});
deleteCollection
Delete an entire collection from the JSON file
database.deleteCollection({ filePath, collectionName, targetID })
.then((successMessage) => {
console.log(successMessage);
})
.catch((error) => {
console.error(error);
});
delete
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);
});
createIndex
Create an index for faster searching.
database.createIndex({ filePath, collectionName, fieldName })
.then((successMessage) => {
console.log(successMessage);
})
.catch((error) => {
console.error(error);
});
Q&A
Discord Server
- Join the Discord Server server for support -
License
This project is under the MIT license. Read more about this license at LICENSE