> For the complete documentation index, see [llms.txt](https://plexidev.gitbook.io/quickdb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://plexidev.gitbook.io/quickdb/master.md).

# Introduction

{% hint style="danger" %}
For all users of quick.db 9.0.0 pre-release (Github version) please check [this page](/quickdb/overview/quick.db-9.0.0-pre-release-upgrade-to-npm.md) out!
{% endhint %}

*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

```ruby
npm install quick.db
```

{% hint style="info" %}
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
{% endhint %}

### 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
```

```javascript
const { QuickDB } = require('quick.db');
const db = new QuickDB(); // using default driver
```

{% hint style="warning" %}
The latest release uses `async/await`. You can read more about the changes [here](/quickdb/overview/changelog.md).
{% endhint %}

## 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.*

```javascript
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']
})();
```
