DBD.DB
Table Of Contents
About
Lightweight Schema-Free Object-Oriented LocalDatabase for Development and Production Purpose
A Object Oriented and Indexs Based Database.
Fast, secure, and easy to use.
Examples
Setup
const BaseDB = require('dbd.db')
const DB = BaseDB('database')
const Collection = DB.collection({
name: "Collection",
ttl: 5 //optional
})
;(async () => {
await Collection.set({
myName: "Matthew",
myHome: "USA"
}, {
myName: "Matthew"
})
console.log(await Collection.find({
myName: "Matthew"
})) //returns [{ myName: "Matthew", myHome: "USA" }]
})()
Creating a Collection
const Collection = DB.collection({
name: "Collection",
ttl: 60 //ttl (Time to Live) in seconds
})
//Interaction with Collection
Interacting with the Collection
await Collection.set({ myName:"Matthew" })
const data = await Collection.findOne({ myName:"Matthew" })
console.log(data) //returns { myName:"Matthew" }
Methods
Core
- Core(name) - The constructor of Database
- Core.deprecated(db, collection) - Transfer old chson into new bison encrypted
- Core.version - Return current version of dbd.db
Database
- Database.collection({ name:"string", ttl:15 }) - Method to create a Collection
- Database.isReady - Condition if database is ready to use
- Database.displayName - The name of the Database
- Database.on('ready', () => void) - Emitted whenever the database is ready to use
Collection
- Collection.db - The main database of the collection
- Collection.displayName - The name of the Collection
- Collection.size - The size of the Collection
- Collection.isOpen - Condition if the Collection is Useable (ready and not closed), Returns Boolean
- Collection.find(filter, limit) - Finds the data in the Collection
- Collection.findOne(filter) - Find one data in the Collection
- Collection.set(data, filter) - Creates a data in the Collection
- Collection.delete(filter, limit) - Delete a data in the collection
- Collection.update(filter, property, value, object?) - Update a data in the collection
- Collection.deleteMany(...filters) - Delete some datas in the collection
- Collection.close() - Close the collection, the data remains in file
- Collection.destroy() - Destroy the connection between the Collection and delete the data in the Collection
- Collection.on('ready', () => void) - Emitted whenever the collection is ready to use
- Collection.on('ttl', (started: Boolean) => void) - Emitted whenever the ttl checking process is started or ended
- Collection.on('expired', (data: Object) => void) - Emitted whenever a data is expired if ttl is active
Links
DBD.DB was made by DBD.JS Team
Special Thanks that made this possible
- Leref - The developer of dbd.js
- Xzusfin - Helping maintain the db
- Kino - Helping at development