是否可以在 sails js 中为现有模型创建一个实例,如下所示?
is it possible to create an instance for an existing model in sails js as below?
var userModel = new User();
userModel.email = req.body.email;
userModel.password = req.body.password;
userModel.save(function(err, user) {
.........
}
Actually i have a model named 'User' and i have to create instance for that to store its attributes temporarily and save it as encapsulated object. But it's showing error from my controller like following..
throw message;
^
TypeError: object is not a function
Is it possible to create like this?
尝试使用model.create()函数。 Documentation Wateline Model.Create
var userModel = new User();
userModel.email = req.body.email;
userModel.password = req.body.password;
userModel.save(function(err, user) {
.........
}
Actually i have a model named 'User' and i have to create instance for that to store its attributes temporarily and save it as encapsulated object. But it's showing error from my controller like following..
throw message;
^
TypeError: object is not a function
Is it possible to create like this?
尝试使用model.create()函数。 Documentation Wateline Model.Create