UNPKG

1.03 kBTypeScriptView Raw
1import 'reflect-metadata';
2import { IndexesOptions as SequelizeIndexOptions } from 'sequelize';
3export interface IndexFieldOptions {
4 name: string;
5 length?: number;
6 order?: 'ASC' | 'DESC';
7 collate?: string;
8}
9export interface IndexesMeta {
10 named: {
11 [name: string]: IndexOptions;
12 };
13 unnamed: IndexOptions[];
14}
15export declare type IndexOptions = Pick<SequelizeIndexOptions, Exclude<keyof SequelizeIndexOptions, 'fields'>>;
16/**
17 * Returns model indexes from class by restoring this
18 * information from reflect metadata
19 */
20export declare function getIndexes(target: any): IndexesMeta;
21/**
22 * Sets indexes
23 */
24export declare function setIndexes(target: any, indexes: IndexesMeta): void;
25/**
26 * Adds field to index by sequelize index and index field options,
27 * and stores this information through reflect metadata. Returns index ID.
28 */
29export declare function addFieldToIndex(target: any, fieldOptions: IndexFieldOptions, indexOptions: IndexOptions, indexId?: string | number): string | number;