當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript core.Container類代碼示例

本文整理匯總了TypeScript中bap-node-microframework/core.Container的典型用法代碼示例。如果您正苦於以下問題:TypeScript Container類的具體用法?TypeScript Container怎麽用?TypeScript Container使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Container類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: define

 static define(mongoose) {
     let friendSchema = {
         name: String,
         email: String
     };
     friendSchema = Container.get('mongoose').Schema(friendSchema);
     return Container.get('mongoose').model('Friend', friendSchema);
 }
開發者ID:bap-node-microframework,項目名稱:standard-edition,代碼行數:8,代碼來源:friend.ts

示例2: oldValue

        descriptor.value = (req, res) => {
            let findOptions = {};

            if (Array.isArray(options.filterBy)) {
                options.filterBy.forEach(col => {
                    findOptions[col] = req.params[col] || req.query[col];
                });
            } else { // object
                Object.keys(options.filterBy).forEach(col => {
                    findOptions[col] = req.params[options.filterBy[col]] || req.query[options.filterBy[col]];
                });
            }

            Container.getModel(options.model).findOne({ where: findOptions }).then(data => {
                if (!data) {
                    return res.status(404).json({
                        error: "Cannot find " + options.model + " with " + JSON.stringify(findOptions)
                    });
                }

                req.params[aName] = data;

                return oldValue(req, res);
            }, error => {
                return res.status(500).json(error);
            });
        };
開發者ID:nicolanrizzo,項目名稱:node-microframework-sequelize,代碼行數:27,代碼來源:paramconverterSequelize.decorators.ts

示例3: post

    post(model: any, form: any, request: any, response: any) {
        if (typeof model === "string") {
            model = Container.getApplicationInstance().getModel(model).build();
        }

        BaseControllerSequelize.processForm(model, form, request, response);
    }
開發者ID:bap-node-microframework,項目名稱:node-microframework-sequelize,代碼行數:7,代碼來源:BaseControllerSequelize.ts

示例4: constructor

 constructor(options) {
     var corsOptions = {
         credentials: options.credentials || true,
         origin: options.origin || function(origin, callback) {
             callback(null, true);
         }
     };
     Container.get('app').use(cors(corsOptions));
 }
開發者ID:nicolanrizzo,項目名稱:node-microframework-cors,代碼行數:9,代碼來源:CorsPlugin.ts

示例5: post

    post(model: any, form: any, request: any, response: any) {
        let postModel;

        let tmp = Container.getApplicationInstance().getModel(model);
        postModel = new tmp({});

        if (typeof model === "string") {
            model = postModel;
        }

        BaseControllerMongoose.processForm(model, form, request, response);
    }
開發者ID:bap-node-microframework,項目名稱:node-microframework-mongoose,代碼行數:12,代碼來源:BaseControllerMongoose.ts

示例6: constructor

 constructor(options) {
     let sequelize = new Sequelize(options.dsn, {
         logging: (process.env.DEBUG || options.debug) ? console.log : false,
         define: {
             timestamps: false
         },
         dialectOptions: {
             multipleStatements: true
         }
     });
     Container.registerService('sequelize', sequelize);
 }
開發者ID:nicolanrizzo,項目名稱:node-microframework-sequelize,代碼行數:12,代碼來源:SequelizePlugin.ts

示例7: registerModels

 registerModels() {
     Container.registerModel('Friend', FriendModel.define(Container.get('mongoose')));
 }
開發者ID:bap-node-microframework,項目名稱:standard-edition,代碼行數:3,代碼來源:index.ts

示例8: cget

 cget(res: any, model: any) {
     Container.getApplicationInstance().getModel(model).findAll().then(
         (data) => { res.status(200).json(data) },
         (err) => { res.status(404).json({ error: err }); }
     );
 }
開發者ID:bap-node-microframework,項目名稱:node-microframework-sequelize,代碼行數:6,代碼來源:BaseControllerSequelize.ts

示例9: constructor

 constructor(app, io) {
     Container.setApplicationInstance(app.container);
     super(app, io);
 }
開發者ID:bap-node-microframework,項目名稱:node-microframework-ping-module,代碼行數:4,代碼來源:PingModule.ts

示例10: constructor

 constructor(options) {
     let mongoose = Mongoose.connect(options.dsn);
     Container.registerService('mongoose', mongoose);
 }
開發者ID:nicolanrizzo,項目名稱:node-microframework-mongoose,代碼行數:4,代碼來源:MongoosePlugin.ts


注:本文中的bap-node-microframework/core.Container類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。