This docs is no more maintained! New Docs: https://enhanceddb.science.repl.co/
So most of them knows what is Enchanced.DB a enchanced version of Quick.DB but this one is recreated without any source code. Then nothing to say! The Docs will say everything
- v0.0.90 of Enchanced.DB or higher
- Basic knowledge with JS
- Better IDE
I was using Quick.DB for some works but i felt so much missing in Quick.DB so i decided to make Enchanced.DB! This package is not made to compete. This is just made to help others using Quick.DB with some more features! This works same as Quick.DB works with less codes using better-sqlite3 and fs. There are no demerits with the package excpet that package stores data in key and value where as Quick.DB stores in ID and data which will make mess if you are using both side by side but if you know Enchanced.DB you can use importQuick() to import datas from Quick.DB!
Import Package
const db = require('enchanced.db')
Set value to the key!
db.set(key, value)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
key | string | ID of the value |
value | string, object or array | Data of the ID |
Get value of the key!
db.get(key)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
key | string | ID of the value |
Get all the data in the database
db.all()
NOTE: Remember if you are doing db.all() this will return data but if you made tables. The data of those tables wont return to get those data you have to do
table.all()
method wheretable
is the constructor. In future we will be solving this problem too!
Will filter data with startsWith() function! This will also return the data startswith the search parameter excluding tables!
db.startsWith(search)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
search | string | String to filter data with startsWith() |
Will return true or false if it has value or not for that key
db.has(key)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
key | string | ID of the value |
Will return tyepof the key
db.type(key)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
key | string | ID of the value |
Will add value to the existing value of the key only if its number
db.add(key, amount)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
key | string | ID of the value |
amount | number | Amount to add |
Will subtract value from the existing value of the key only if its number
db.subtract(key, amount)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
key | string | ID of the value |
amount | number | Amount to subtract |
There are some options which makes this database unique!
db.options(options)
Options:
Options Name | Tyepof | Description | Default |
---|---|---|---|
clearOnStart | boolean | Will clear database on restart of program only if its set to true |
false |
filename | string | Name of the file where data will be stored! | 'enchanced.sqlite' |
NOTE: Use
import()
if you are switching to a new file
Push data to the old value if its an Array
db.push(key, value)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
key | string | ID of the value |
value | any | Value to push |
Will check oldData if it includes value in the OldValue Array
db.includes(key, value)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
key | string | ID of the value |
value | any | Value to check if its included! |
Will delete value of the key
db.delete(key)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
key | string | ID of the value |
Will delete all values of the keys. This will support only to the deafult database table not to the custom tables....
db.deleteAll()
Import data from table to table or table to default table or vice versa but only for {key: key, value: value}
type stored data!
db.import(data)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
data | object | all() Only Enchanced.DB data only! |
Import data from Quick.DB table data or default table data!
const quick = require('quick.db')
const db = require('enchanced.db')
db.importQuick(quick.all())
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
data | object | all() Only Quick.DB data only! |
So if you are Quick.DB user you know what is this. Till now you have use default database table named database
but using the Table
constructor you can make custom Sqlite Database Tables with custom names and options too
const { Table } = require('enchanced.db')
const table = new Table(tableName, options)
Parameters:
Parameter Name | Tyepof | Description |
---|---|---|
tableName | string | Your custom table name |
options | object | Same as options() method in the default database table! Options: clearOnStart and filename |
If you have read the docs from first then you have learnt Enchanced.DB finally because Table
constructor has same methods!
Methods: set
, get
, all
, startsWith
, has
, type
, add
, subtract
, delete
, deleteTable
, import
, importQuick
, push
, includes
Note: There is no use of
options()
function inTable
constructor because you can set it in the constructor parameter Options itself. And you need to usedeleteTable()
function instead ofdeleteAll()
for custom tables!
- Discord Server Link: https://discord.gg/FrduEZd
- GitHub Repo Link: https://github.com/scientific-dev/enchanced.db