本文整理匯總了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);
}