sequelize-mv-support
Version:
Adds materialized views support to Sequelize.
82 lines • 2.61 kB
TypeScript
import { DropOptions, Model as ModelOrig, ModelOptions, SyncOptions } from 'sequelize';
import type { Sequelize, QueryInterfaceWithViews } from './SequelizeWithViews';
/**
* Interface describing the options property on a model
*
* @export
* @interface ModelOptionsWithViews
* @extends {ModelOptions}
*/
export interface ModelOptionsWithViews<M extends ModelOrig> extends ModelOptions<M> {
treatAsView?: boolean;
treatAsMaterializedView?: boolean;
viewDefinition?: string;
materializedViewDefinition?: string;
}
export type DropOptionsType = DropOptions & {
treatAsView?: boolean;
treatAsMaterializedView?: boolean;
viewDefinition?: string;
};
export type OptionsType = ModelOptionsWithViews<ModelOrig> & {
sequelize: Sequelize;
};
/**
* Model with view support added
*
* @export
* @class Model
* @extends {ModelOrig}
*/
export declare class Model<TModelAttributes extends {} = any, TCreationAttributes extends {} = TModelAttributes> extends ModelOrig<TModelAttributes, TCreationAttributes> {
/** @inheritdoc */
static readonly options: OptionsType;
/** @inheritdoc */
static queryInterface: QueryInterfaceWithViews;
/** @inheritdoc */
static drop(options?: DropOptionsType): any;
/** @inheritdoc */
static sync(options: SyncOptions): any;
/**
* Executes the query to create a view
*
* @static
* @returns {Promise<[unknown[], unknown]>} Result of the create view request
* @memberof Model
*/
static syncView(): Promise<[unknown[], unknown]>;
/**
* Executes the query to create a materialized view
*
* @static
* @returns {Promise<[unknown[], unknown]>} Result of the create materialized view request
* @memberof Model
*/
static syncMaterializedView(): Promise<[unknown[], unknown]>;
/**
* Gets the sql definition for this view
*
* @static
* @returns {string} SQL query string to create a view
* @memberof Model
*/
static getViewDefinition(): string | undefined;
/**
* Gets the sql definition for this materialized view
*
* @static
* @returns {string} SQL query string to create the materialized view
* @memberof Model
*/
static getMaterializedViewDefinition(): string | undefined;
/**
* Refreshes the materialized view in the database
*
* @static
* @returns {Promise<[unknown[], unknown]>}
* @memberof Model
*/
static refreshMaterializedView(): Promise<[unknown[], unknown]>;
}
export default Model;
//# sourceMappingURL=ModelWithViews.d.ts.map