UNPKG

sequelize-store

Version:
44 lines (43 loc) 2.04 kB
import type { Sequelize } from 'sequelize'; import { Schema, StoreObject, StoreOptions } from './definitions'; export { StoreObject, StoreOptions, Type, NativeTypes, ValueOptions, Schema } from './definitions'; /** * Function that returns a Promise that is resolved when the DB processing queue * is finished with all the pending transactions. If queue is empty Promise is * resolved right away. * * Be aware that since the queue is in "autostart" mode if you modify the store * after the Promise resolution the queue will start again processing the requests * but this Promise won't "unresolve" as that is restriction of Promises. * * This function should be always at the end of your application life-cycle in order * to guarantee that all information is persisted! */ export declare function getEndPromise(): Promise<void>; /** * Function mainly for testing. * It resets the internal store object that is always returned by the getObject(). * Hence init() can be then called again with new schema. * !!! Be aware !!! If used without understanding this might break things! */ export declare function reset(): void; /** * Returns the Store's object that uses the Schema defined in init(). * Always return the same object so can be called from anywhere as many times you need. * * @param scope - It is possible to get an object that has scoped the namespace to some prefix defined by this parameter. */ export declare function getObject(scope?: string): StoreObject; /** * Purge database of all data and also purges the local cache. */ export declare function purge(): void; /** * Initialize Sequelize Store for usage. * This adds the Sequelize Storage model to Sequelize and validate Schema. * * @param sequelize - Instance of Sequelize to be used for the Store * @param schema - Object that define scheme of the Store. * @param tableName - Name of the table to be used for storing the data. */ export declare function init(sequelize: Sequelize, schema: Schema, { tableName }?: StoreOptions): Promise<void>;