meatdb
v2.1.0
Published
Package that can store your data with easy, secure and fast
Downloads
17
Maintainers
Readme
meatdb / meat.db
Package that can store your data with easy, secure and fast
Installation ⏳
You can install via npm using this command:
npm i meatdb
Setup 🔨
const DB = require('meatdb'); // Common JS import
// or
import DB from 'meatdb'; // ESM import
Usage 📌
const db = new DB({
path: './database', //optional
waitForSetTime: 50, //(optional default to 50) wait for a given time in ms before set the data
maxDataInOneFile: 10000, //(optional default to 10000) maximum data in one file, it'll create a new file if it's reach the limit
encrypt: true, // optional, default to false
encryptionKey: "Very secret key, you must hide this key somewhere in the safe place like env", // required only if encrypt is true
iv: 'my iv 123', //required only if encrypt is true
salt: "salt", //optional only affected when encrypt is true
encoding: "binary" //optional default to hex only affected when encrypt is true
})
db.once('ready', () => {
console.log("Database ready!")
})
// NOTE: you need to use .then() if it's not in async function
// set data with provided name and value
await db.set('name', 'value') // return undefined
// get data with provided name
await db.get('name') // return json {key: 'name', value: 'value'} or value become undefined if it doesn't exist
// check if data with provided name exist
await db.has('name') // return true or false depend on if the data exist or not
// delete data with provided name
await db.delete('name') // return true or false depend on if the data exist or not (like db.has but it'll delete the data if exist)
// get all data that has been stored in the db
await db.all() // return array with json inside it. Actually like db.get
// get database ping
await db.ping() // return number in ms
//get database uptime
db.uptime // return number in ms
Why using this package?
because this package is fast and easy to store your data, need only 300 - 800ms to set 100k data in the same time, also you can encrypt your data with easy and your data will be secure
You can try this:
// not encrypt
const DB = require('meatdb')
const db = new DB()
for (let i = 0; i < 100000; i++) {
db.set(i, i)
}
// encrypt
const DB = require('meatdb')
const db = new DB({
encrypt: true,
encryptionKey: 'secret key here',
iv: 'this is iv'
})
for (let i = 0; i < 100000; i++) {
db.set(i, i)
}
What's new on 2.1.0?
- Support more node.js version