83db
v1.0.2
Published
Entirely encrypted and GZip compressed JSON Database
Downloads
12
Maintainers
Readme
Getting Started
83db is a CURD, GZip compressed, JSON database with optional AES-256-CBC encryption
Simple DB:
const Database = require("83db");
module.exports.UserDB = new Database('./users.db', {
dir: __dirname // This is needed for local paths
})
Encrypted DB:
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();