Introduction
This package is meant to provide an easy way to create and use a database, all data is stored persistently, and comes with additional easy to use features.
Installation
1
npm install quick.db
Copied!
Require Package
1
var db = require('quick.db')
Copied!

What is Quick.db?

Quick.db is an easy-to-use database manager built with better-sqlite3. It's simple by design and perfect for smaller projects where you don't want to set up a separate database server or individuals who may be getting started with programming.

Example

All data in quick.db is stored persistently in a database. Here is an example of setting an object in the database, then fetching parts & the full object.
1
const db = require('quick.db');
2
3
// Setting an object in the database:
4
db.set('userInfo', { difficulty: 'Easy' })
5
// -> { difficulty: 'Easy' }
6
7
// Pushing an element to an array (that doesn't exist yet) in an object:
8
db.push('userInfo.items', 'Sword')
9
// -> { difficulty: 'Easy', items: ['Sword'] }
10
11
// Adding to a number (that doesn't exist yet) in an object:
12
db.add('userInfo.balance', 500)
13
// -> { difficulty: 'Easy', items: ['Sword'], balance: 500 }
14
15
// Repeating previous examples:
16
db.push('userInfo.items', 'Watch')
17
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 }
18
db.add('userInfo.balance', 500)
19
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 1000 }
20
21
// Fetching individual properties
22
db.get('userInfo.balance') // -> 1000
23
db.get('userInfo.items') // -> ['Sword', 'Watch']
24
25
// Showing dot notation setting
26
db.set('userInfo.difficulty', 'Hard')
27
// -> { difficulty: 'Hard', items: ['Sword', 'Watch'], balance: 1000 }
28
29
db.get('userInfo.difficulty') // -> 'Hard'
Copied!

Our Sponsor

Need A VPS? Get started with Contabo!   Up to 60 GB RAM - 10 Cores - Unlimited Traffic   Starting at €3.99  
Last modified 1yr ago