当前位置: 动力学知识库 > 问答 > 编程问答 >

sails.js - Data getting inserted in the sails js database even when it should not

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: