83db

1.0.2 • Public • Published

Getting Started

83db is a CURD, GZip compressed, JSON database with optional AES-256-CBC encryption

Simple DB:


First, create a new JS file for your database, For this example I will make a file named `users.js` and a database file named `users.db`
const Database = require("83db");

module.exports.UserDB = new Database('./users.db', {
    dir: __dirname // This is needed for local paths
})

Encrypted DB:


Same steps as before, but add the `decryptionKey` option.
const Database = require("83db");

module.exports.UserDB = new Database('./users.db', {
    dir: __dirname, // This is needed for local paths
    decryptionKey: "256 bit ( 16 hex characters ) decryption key, store in env"
})

Functions


get(key: string)

  • Gets the value in a DB with the key, key
  • Returns the key's value

set(key: string, value: any)

  • Sets a key's value, or creates it if it doesnt exist.
  • Returns Database

delete(key: string)

  • Deletes the value with the key, key
  • Returns Database

list(prefix: string?)

  • List all keys with an optional prefix
  • Returns string[]

empty()

  • Empties the entire database
  • Returns Database

exists(key: string)

  • Checks if a key, key exists
  • Returns Boolean

write(encryptionKey : string?)

  • Writes all data to the file, you can override the encryption key with the optional encryptionKey parameter
  • Returns Database

getAll()

  • Returns an object with all the keys and values like { key: value ... }
  • Returns object

setAll(obj : object?)

  • Sets the database's JSON to a specified object obj
  • Returns Database

Examples


Creates a key named "John" and has a value of { lastName: "Doe" }

const Database = require("83db");

const users = new Database('./users.db', {
    dir: __dirname
});

users.set("John", {
    lastName: "Doe"
}).write();

Package Sidebar

Install

npm i 83db

Weekly Downloads

6

Version

1.0.2

License

BSD-3-Clause

Unpacked Size

4.72 kB

Total Files

3

Last publish

Collaborators

  • elijah629