mewwme.quick.db
TypeScript icon, indicating that this package has built-in type declarations

9.7.0 • Public • Published

Installation

npm i mewwme.quick.db

Example With MySQLDriver

NOTE: In order to use this driver, install npm i mysql2 separately.

const { QuickDB } = require("mewwme.quick.db");
const { MySQLDriver } = require("mewwme.quick.db/MySQLDriver");
(async () => {
    const mysqlDriver = new MySQLDriver({
        host: "localhost",
        user: "me",
        password: "secret",
        database: "my_db",
    });

    const db = new QuickDB({ driver: mysqlDriver });
    await db.init(); // Connects and setup the database
    // Now you can use mewwme.quick.db as normal

    await db.set("userInfo", { difficulty: "Easy" });
    // -> { difficulty: 'Easy' }
})();

Example With PostgresDriver

NOTE: In order to use this driver, install npm i pg separately.

const { QuickDB } = require("mewwme.quick.db");
const { PostgresDriver } = require("mewwme.quick.db/PostgresDriver");
(async () => {
    const postgresDriver = new PostgresDriver({
        host: "localhost",
        user: "me",
        password: "secret",
        database: "my_db",
    });

    const db = new QuickDB({ driver: postgresDriver });
    await db.init(); // Connects and setup the database
    // Now you can use mewwme.quick.db as normal

    await db.set("userInfo", { difficulty: "Easy" });
    // -> { difficulty: 'Easy' }
})();

Example With MongoDriver

NOTE: In order to use this driver, install npm i mongoose separately.

const { QuickDB } = require("mewwme.quick.db");
const { MongoDriver } = require("mewwme.quick.db/MongoDriver");
(async () => {
    const mongoDriver = new MongoDriver("mongodb://localhost/quickdb");

    const db = new QuickDB({ driver: mongoDriver });
    await db.init(); // Connects and setup the database
    // Now you can use mewwme.quick.db as normal

    await db.set("userInfo", { difficulty: "Easy" });
    // -> { difficulty: 'Easy' }

    await mongoDriver.close();
    // disconnect from the database
})();

Example With JSONDriver

NOTE: In order to use this driver, install npm i write-file-atomic separately.

const { QuickDB } = require("mewwme.quick.db");
const { JSONDriver } = require("mewwme.quick.db/JSONDriver");
const jsonDriver = new JSONDriver();
const db = new QuickDB({ driver: jsonDriver });

// Init the database, this is always needed!
await db.init();
await db.set("userInfo", { difficulty: "Easy" });

Example With MemoryDriver

Note: In-memory database is not persistent and is suitable for temporary caching.

const { QuickDB } = require("mewwme.quick.db");
const { MemoryDriver } = require("mewwme.quick.db/MemoryDriver");
const memoryDriver = new MemoryDriver();
const db = new QuickDB({ driver: memoryDriver });

// Init the database, this is always needed!
await db.init();
await db.set("userInfo", { difficulty: "Easy" });

Package Sidebar

Install

npm i mewwme.quick.db

Homepage

meww.me/

Weekly Downloads

16

Version

9.7.0

License

MIT

Unpacked Size

108 kB

Total Files

71

Last publish

Collaborators

  • lrmn7