PineappleRind / DoodleDB

DoodleDB is a lightweight package that allows you to utilize JSON files as databases

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Import the class into your Node.js application
import { DoodleDB } from "doodledb";
  1. Instantiate the class with the path to the JSON file
const database = new DoodleDB({ filePath: "database.json" });
  1. 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

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.

Discord Server

License

This project is under the MIT license. Read more about this license at LICENSE

About

DoodleDB is a lightweight package that allows you to utilize JSON files as databases

License:MIT License


Languages

Language:TypeScript 100.0%