本文整理汇总了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);
}
示例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));
}
示例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);
}
示例7: registerModels
registerModels() {
Container.registerModel('Friend', FriendModel.define(Container.get('mongoose')));
}
示例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);
}
示例10: constructor
constructor(options) {
let mongoose = Mongoose.connect(options.dsn);
Container.registerService('mongoose', mongoose);
}