问题描述:

I am new to sails js. I created a model :

 module.exports = {

attribute: {

firstName:{

type: 'string',

required: true,

},

};

and the data was getting inserted even if i pass " firstName:'' ". It was happening because it should be "attributes" and not "attribute". Can anyone tell me why they both are different? Thank you.

网友答案:

Well, your key attribute that specifies a model's attributes was wrong so it treated the model as if there were no required attributes (or any at all). The parameter can still be passed when creating the model, but nothing would be done with it. That means that a model instance would still be created regardless of what parameters you passed or did not pass in.

See the Waterline documentation for more details about models.

相关阅读:
Top