本文整理汇总了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;未经允许,请勿转载。 |
请发表评论