Socket
Socket
Sign inDemoInstall

dbdjs.db

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dbdjs.db

dbdjs.db - JSON Database with Speed and Optimization.


Version published
Weekly downloads
1.3K
increased by181.51%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

dbd.js

dbdjs.db

Discord Server NPM Downloads NPM Version

Table Of Contents

About

dbdjs.db is a JSON Database meant for quick and easy saving data values.

Setup

const DBDJSDB = require("dbdjs.db");
const db = new DBDJSDB.Database({
  path: "database",
  tables: {{
    name: "test",
  }},
});

db.once("ready", () => {
  console.log("Database ready!");
});

db.connect();

Set

await db.set("test", "apple", "turtle.");
await db.set("test", "leref", "dbdjs.db owner");

Get

const apple = await db.get("test", "apple");
const leref = await db.get("test", "leref");

Get All

const lerefAndApple = await db.all("test", {
  filter: ({ data }) => data.key.includes("w"),
});

Delete

await db.delete("test", "apple");
await db.delete("test", "leref");

API

#Database

ParamsDescription
options: DatabaseOptionsThe database constructor to make a new database instance.
  • #set()
    ParamsReturnDescription
    table: string, key: string, value: anyPromise<boolean>Set method for the database.
  • #get()
    ParamsReturnDescription
    table: string, key: stringPromise<Data>Get method for the database.
  • #all()
    ParamsReturnDescription
    table: string, options: AllOptionsPromise<AllData[]>GetAll method for the database.
  • #delete()
    ParamsReturnDescription
    table: string, key: stringPromise<boolean>Delete method for the database.

Interfaces

Database Options

PropertyValueDefaultDescription
tablesTable[]The reserved tables for the database.
path?string"database"Path to main database folder.
maxFileData?number50000The max data that a file can store.
debug?booleanfalseWhether the database should send debug log events.
extension?string".sql"The extension for each file in the database.
force?booleanfalseWhether to force the database to save or delete data on the file.
cache?number3000How many data can the database store in memory cache.
timestamp?booleanfalseWhether the database should save timestamp for each data.
saveTime?number100How long until the database can save the data into file (ms).
getTime?number1How long until the database pull a data from file (ms).
allTime?number100How long until the database pull some data from file (ms).
deleteTime?number100How long until the database delete a data from file (ms).
cacheRouters?booleantrueWhether the database should cache data routers on startup.

Table

PropertyValueDescription
namestringName for the table, this will also define the path to this table file.

Data

PropertyValueDescription
keystringThe key of the data.
valueanyThe value of the data.
ttl?numberThe ttl for the data.
createdAt?numberThe time which this data was created.
updatedAt?numberThe time which this data was last updated.

All Options

PropertyValueDescription
filter(allData: AllData) => booleanThe function to filters data.

All Data

PropertyValueDescription
keystringThe key of the data.
dataDataThe data object of the data.

dbdjs.db was created for dbd.js now available for anyone to learn and use.

Keywords

FAQs

Last updated on 26 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc