breeze-sequelize
Version:
Breeze Sequelize server implementation
36 lines (35 loc) • 1.62 kB
TypeScript
import { Sequelize, Options, SyncOptions } from "sequelize";
import { MetadataStore, DataProperty } from "breeze-client";
import { DbConfig } from "./dbUtils";
import { NameModelMap } from "./MetadataMapper";
export interface KeyGenerator {
getNextId: (prop: DataProperty) => any;
}
/** Manages the Sequelize instance for Breeze query and save operations */
export declare class SequelizeManager {
static Sequelize: typeof Sequelize;
sequelizeOptions: Options;
dbConfig: DbConfig;
sequelize: Sequelize;
/** Same as resourceNameSqModelMap */
models: NameModelMap;
/** Maps resource name to Sequelize Model */
resourceNameSqModelMap: NameModelMap;
/** Maps entity type name to Sequelize Model */
entityTypeSqModelMap: NameModelMap;
metadataStore: MetadataStore;
/** Generates keys for entity types where autoGeneratedKeyType = "KeyGenerator" */
keyGenerator: KeyGenerator;
constructor(dbConfig: DbConfig, sequelizeOptions: Options);
/** Connect to the database */
authenticate(): Promise<void>;
/** Create a new database */
createDb(): Promise<void>;
/** Import Sequelize models, create Breeze metadata from the models, and build the maps between them. */
importModels(modelDir: string, namespace: string): void;
/** Convert Breeze metadata to Sequelize models */
importMetadata(breezeMetadata: MetadataStore | string | Object): void;
/** Sync the Sequelize model with the database */
sync(shouldCreateDb: boolean, sequelizeOpts: SyncOptions): Promise<Sequelize>;
private syncCore;
}