From 683298dde706b34bdbdb6abd0cab6a7164495967 Mon Sep 17 00:00:00 2001 From: supperchong <2267805901@qq.com> Date: Fri, 19 Jul 2019 13:39:08 +0800 Subject: [PATCH] docs: add comment in index.d.ts (#78) --- index.d.ts | 22 +++++++++++++++++++--- lib/loader.js | 6 +++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9336bba..b1c57b3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,9 +1,26 @@ import * as sequelize from 'sequelize'; interface EggSequelizeOptions extends sequelize.Options { + /** + * load all models to `app[delegate]` and `ctx[delegate]`, default to `model` + */ delegate?: string; + + /** + * load models from `app/model/*.js` + */ baseDir?: string; - exclude?: string; + + /** + * ignore `app/${baseDir}/index.js` when load models, support glob and array + */ + exclude?: string | Array; + + /** + * A full database URI + * @example + * `connectionUri:"mysql://localhost:3306/database"` + */ connectionUri?: string; } @@ -12,7 +29,7 @@ interface DataSources { } declare module 'egg' { - interface IModel extends sequelize.Sequelize, PlainObject { } + interface IModel extends sequelize.Sequelize, PlainObject {} // extend app interface Application { @@ -29,5 +46,4 @@ declare module 'egg' { interface EggAppConfig { sequelize: EggSequelizeOptions | DataSources; } - } diff --git a/lib/loader.js b/lib/loader.js index a669ec6..2568699 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -41,11 +41,11 @@ module.exports = app => { }); /** - * load databse to app[config.delegate + * load database to app[config.delegate] * @param {Object} config config for load * - delegate: load model to app[delegate] - * - baeDir: where model located - * - other sequelize configures(databasem username, password, etc...) + * - baseDir: where model located + * - other sequelize configures(database username, password, etc...) * @return {Object} sequelize instance */ function loadDatabase(config = {}) {