import { DatabaseFactory } from './DatabaseFactory'; import { ModelFactory } from './ModelFactory'; import { Chance } from 'chance'; import { ApplicationContract } from '../../Contracts/ApplicationContract'; export interface Blueprint { name: string; callback: (faker: Chance, index: number, data: any) => Promise; } /** * Factory class is used to define blueprints * and then get model or database factory * instances to seed the database. * * @class Factory * @constructor */ export declare class DBFactory { app?: ApplicationContract; protected _blueprints: Blueprint[]; constructor(app?: ApplicationContract); /** * Register a new blueprint with model or table name * and callback to be called to return the fake data * for model instance of table insert query. * * @method blueprint * * @param {String} name * @param {Function} callback * * @chainable * * @example * ```js * Factory.blueprint('App/Model/User', (fake) => { * return { * username: fake.username(), * password: async () => { * return await Hash.make('secret') * } * } * }) * ``` */ blueprint(name: any, callback: any): this; /** * Returns the blueprint map with the map * and the callback. * * @method getBlueprint * * @param {String} name * * @return {Object} */ getBlueprint(name: any): Blueprint | undefined; /** * Get model factory for a registered blueprint. * * @method model * * @param {String} name * * @return {ModelFactory} */ model(name: any): ModelFactory; /** * Get database factory instance for a registered blueprint * * @method get * * @param {String} name * * @return {DatabaseFactory} */ get(name: any): DatabaseFactory; /** * Clear all the registered blueprints. * * @method clear * * @return {void} */ clear(): void; }