UNPKG

dynamic-record

Version:

A bare minimum Javascript implementation of the Active Record pattern

43 lines (42 loc) 2.08 kB
import { DRConnection } from "./interfaces/connection"; /** * Create a connection object that can be used by DynamicRecord instances. * * @method createConnection * @param {string} url Full connection URL for the database in question * @return {object} - Return the created connection object */ export declare function createConnection(url: string): DRConnection; import { DynamicRecord } from "./DynamicRecord"; export { DynamicRecord } from "./DynamicRecord"; export { Model as DynamicModel } from "./DynamicRecord"; /** * Create an instance of DynamicRecord that uses established connection. * * @method createInstance * @param {object} connection Connection object created with `createConnection()` * @param {string} tableSlug Identifier for the table to use with this instance * @return {DynamicRecord} - Return the created DynamicRecord instance */ export declare function createInstance<DataObject extends object>(connection: DRConnection, tableSlug: any): DynamicRecord<DataObject>; export { DynamicSchema } from "./DynamicSchema"; import { DynamicSchema } from "./DynamicSchema"; /** * Create an instance of DynamicSchema that uses established connection. * * @method createSchemaInstance * @param {object} connection Connection object created with `createConnection()` * @return {DynamicSchema} - Return the created DynamicSchema instance */ export declare function createSchemaInstance(connection: DRConnection): DynamicSchema; export { DynamicCollection } from "./DynamicCollection"; import { DynamicCollection } from "./DynamicCollection"; /** * Create an instance of DynamicCollection that uses established connection. * * @method createCollection * @param {object} connection Connection object created with `createConnection()` * @param {object} Model The Model constructor to use for this collection * @return {DynamicCollection} - Return the created DynamicCollection instance */ export declare function createCollection<DataObject extends object>(connection: DRConnection, Model: any, ...data: any[]): DynamicCollection<DataObject>;