ervel.db

3.2.1 • Public • Published

Typing SVG

Downloads DownloadPerMonth Version

Updates

  • Some typos and performance fixes.
  • Added a new option 'minify' to set database format.
  • Updated backup function now you can set when do you want to save backup.
  • Fixed FileFixer on JSON Provider that was not working properly.
db.backup() //Creates the ervel-backup.json file.
db.backup("./backup/file") //Creates a backup file named "file" in the "./backup" directory.
db.backup("./backup/file", "1m") //Automatically creates and updates a backup file named "file" in the "./backup" directory every 1 minute. 1s, 1m ,1h
const { JsonProvider } = require("ervel.db")
const db = new JsonProvider({ minify: true })

//This will save the database in a minified format
database: {data1: "value", data2: "value"}
const { JsonProvider } = require("ervel.db")
const db = new JsonProvider({ minify: false }) //You don't have to provide this option if you are going to use the default value, which is false.

//This will save the database in a formatted (non-minified) format
database: { 
data1: "value", 
data2: "value"
}

About

• Ervel.db is a beginner-friendly module that caters to new developers and allows easy usage of databases with a simple key-value structure. It encompasses popular database modules such as Mongodb, Bson, Yaml, and Json. In the future, it will be enriched with support for additional database types.

Features

  • Beginner friendly, All In One and Easy to use.
  • Personalizable separator in JSON, BSON and YAML databases.
  • Key and Value based methods.
  • Quick to respond, read and write.
  • Mongo Multiple model support.
  • Easy to switch between JSON, BSON, YAML and Mongodb databases.
  • Supports EventEmitter functions in JSON, BSON and YAML databases.
  • Auto database typo fixer in JSON database.
  • Auto Update Checker.
  • Minify option on JSON database.
const db = new JsonProvider({}) //Every options is set to default.
const db = new JsonProvider({ path: "./files/advanceduser.json", separator: "*", useEmit: true, checkUpdate: false, minify: true }) //Every options has been changed to user choice.

Close Auto Check Update

const { JsonProvider } = require("ervel.db")
const db = new JsonProvider({ checkUpdate: false })

EventEmitter Usage Example

  • EventEmitter Options: set, clear, move, destroy, pull, push, delete, add, sub, backup
const { JsonProvider } = require("ervel.db")
const db = new JsonProvider({ useEmit: true })

db.on('set', ({ key, value }) => {
console.log(`key: ${key} value: ${value}`);
});

db.set("test", "test")

All Local Provider Methods

const { YamlProvider, BsonProvider, JsonProvider } = require("ervel.db")
const db = new YamlProvider({ path: "./ervel.yml" }) //The file name, file location and separator can be personalizable. Default separator is ".".
const db = new BsonProvider({ path: "./ervel.bson" }) 
const db = new JsonProvider({ path: "./ervel.json" }) 

db.set("key", "value") //key: "value"

db.fetch("key") //"value"

db.get("key") //"value"

db.has("key") //true

db.push("array", "data") //array: ["data"]

db.pull("array", "data") //array: []

db.fetchAll() //{ key: "value", array: [] }

db.all() // { key: "value", array: [] }
db.all("object") //[ [key: "value"], [array: []] ]
db.all("keys") //["key", "array"]
db.all("values") //["value", []]

db.length() //Shows the number of data in the database.
db.length("key") //Shows the number of data in the "key" data.

db.type("key") //string

db.startsWith("key") //Lists data entries whose keys start with the keyword "key". [ keyanime: "value" ]

db.endsWith("key") //Lists data entries whose keys end with the keyword "key". [ animekey: "value" ]

db.includes("key") //Lists data entries that include the keyword "key". [ animekey: "value", keyanime: "value" ]

db.delete("key") //Deletes the "key" data.

db.clear() //Deletes all data in the database.

db.backup() //Creates the ervel-backup.json file.
db.backup("./backup/file") //Creates a backup file named "file" in the "./backup" directory.
db.backup("./backup/file", "1m") //Automatically creates and updates a backup file named "file" in the "./backup" directory every 1 minute. 1s, 1m ,1h

db.move(quick) //Moves Quick.db data to Local Provider.

db.add("number", 1) //number: 2

db.sub("number", 1) //number: 0

db.destroy() //Deletes the database file.

db.size() //Shows database size.

db.version() //3.2.1

All Mongo Methods

const { MongoProvider } = require("ervel.db");
const db = new MongoProvider("mongodb://localhost/ervel.db");

db.set("key", "value") //key: "value"

db.fetch("key") //"value"

db.get("key") //"value"

db.has("key") //true

db.push("array", "data") //array: ["data"]

db.pull("array", "data") //array: []

db.fetchAll() //{ key: "value", array: [] }

db.all() //{ key: "value", array: [] }

db.export() //Exports all data from the database.

db.import() //Imports all data from the database.

db.type("key") //string

db.uptime() //Shows connection uptime.

db.connection() //Shows connection status.

db.keyArray() //["key", "array"]

db.valueArray() //["value", []]

db.delete("key") //Deletes the "key" data.

db.clear() //Deletes all data in the database.

db.add("number", 1) //number: 2

db.sub("number", 1) //number: 0

db.move(quick) //Moves Quick.db data to Mongodb database.

db.disconnect() //Disconnects database connection.

db.createModel("name") //Creates model.

db.updateModel("name") //Updates the model name.

db.version() //3.2.1

Moving Data From Quick.DB to Mongodb

const { MongoProvider } = require("ervel.db");
const db = new MongoProvider("mongodb://localhost/ervel.db");

const { QuickDB } = require("quick.db");
const quick = new QuickDB();

db.move(quick)   

Moving Data From Quick.DB to Local Database

const { YamlProvider, BsonProvider, JsonProvider } = require("ervel.db")
const db = new YamlProvider({ path: "./ervel.yml" })  //The file name, file location and separator can be personalizable. Default separator is ".".

const { QuickDB } = require("quick.db");
const quick = new QuickDB();

db.move(quick)

Ervel.db by Ervel is licensed under CC BY-NC-ND 4.0

Package Sidebar

Install

npm i ervel.db

Weekly Downloads

138

Version

3.2.1

License

CC BY-NC-ND 4.0

Unpacked Size

81.9 kB

Total Files

12

Last publish

Collaborators

  • ervel