JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q41981F
  • License BSD-3-Clause

Entirely encrypted and GZip compressed JSON Database

Package Exports

  • 83db
  • 83db/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (83db) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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();