Class MongoDriver

Quick.db compatible mongo driver

Example

// require quickdb
const { QuickDB } = require("quick.db");
// require mongo driver from quickmongo
const { MongoDriver } = require("quickmongo");
// create mongo driver
const driver = new MongoDriver("mongodb://localhost/quickdb");

// connect to mongodb
await driver.connect();

// create quickdb instance with mongo driver
const db = new QuickDB({ driver });

// set something
await db.set("foo", "bar");

// get something
console.log(await db.get("foo")); // -> foo

Hierarchy

  • MongoDriver

Implements

Constructors

Properties

conn?: Connection
docSchema: Schema<CollectionInterface<unknown>, Model<CollectionInterface<unknown>, any, any, any, any>, {}, {}, {}, {}, DefaultSchemaOptions, CollectionInterface<unknown>>
models: Map<string, Model<CollectionInterface<unknown>, {}, {}, {}, any>> = ...
mongoose: __module
options: ConnectOptions = {}
url: string

Methods

  • Parameters

    • Optional force: boolean

    Returns Promise<void>

  • Parameters

    • table: string

    Returns Promise<{
        id: string;
        value: any;
    }[]>

  • Type Parameters

    • T

    Parameters

    • table: string
    • key: string

    Returns Promise<[null | T, boolean]>

  • Type Parameters

    • T

    Parameters

    • table: string
    • key: string
    • value: any

    Returns Promise<T>

Generated using TypeDoc