1.4.5 • Published 3 years ago

dbd.db v1.4.5

Weekly downloads
8,591
License
MIT
Repository
-
Last release
3 years ago

DBD.DB

Discord Server NPM Version NPM Downloads

NPM Info

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
1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.19

3 years ago

1.3.17

3 years ago

1.3.18

3 years ago

1.3.16

3 years ago

1.3.15

3 years ago

1.3.14

3 years ago

1.3.13

3 years ago

1.3.12

3 years ago

1.3.11

3 years ago

1.3.10

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago