🎉Introduction

For all users of quick.db 9.0.0 pre-release (Github version) please check this page out!

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

npm install quick.db

The SQLite driver is used by default. Alternatively, you can use the MySQL driver. If better-sqlite3 is installed to use the SQLite, there is no need to install promise-mysql

SQLite Driver installation

To use the SQLite driver. installing better-sqlite3 is necessary

npm install better-sqlite3

MySQL Driver installation

To use the MySQL driver. installing promise-mysql is necessary

npm install promise-mysql
const { QuickDB } = require('quick.db');
const db = new QuickDB(); // using default driver

The latest release uses async/await. You can read more about the changes here.

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.

const { QuickDB } = require("quick.db");
const db = new QuickDB(); // will make a json.sqlite in the root folder
// if you want to specify a path you can do so like this
// const db = QuickDB({ filePath: "source/to/path/test.sqlite" });

(async () => {
    // self calling async function just to get async
    // Setting an object in the database:
    await db.set("userInfo", { difficulty: "Easy" });
    // -> { difficulty: 'Easy' }

    // Pushing an element to an array (that doesn't exist yet) in an object:
    await db.push("userInfo.items", "Sword");
    // -> { difficulty: 'Easy', items: ['Sword'] }

    // Adding to a number (that doesn't exist yet) in an object:
    await db.add("userInfo.balance", 500);
    // -> { difficulty: 'Easy', items: ['Sword'], balance: 500 }

    // Repeating previous examples:
    await db.push("userInfo.items", "Watch");
    // -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 }
    await db.add("userInfo.balance", 500);
    // -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 1000 }

    // Fetching individual properties
    await db.get("userInfo.balance"); // -> 1000
    await db.get("userInfo.items"); // ['Sword', 'Watch']
})();

Last updated