Answer the question
In order to leave comments, you need to log in
How to write only what is needed in the model?
Hello. Happy New Year
I have an Items model created in sail.js
module.exports = {
attributes: {
en: {type: 'string'},
ru: {type: 'string'}
}
};
module.exports = {
addItem: function(req, res) {
var params = {
en : req.en,
ru : req.ru
};
Items.addItem(params, function(success) {
res.json(success);
});
}
};
module.exports = {
addItem: function(params, next) {
Items.create({value: params}).exec(function(err, item) {
if(err) throw err;
next(item);
});
}
};
site.com/items?ru=имя&en=name
and everything is in order. Everything is recorded. But if I do site.com/items?name=name
(well, or some other), then a separate name field is still written to the database. And I would like to write only in ru and en - without the ability to create some separate fields by the user. How (and where) can it be validated?
Answer the question
In order to leave comments, you need to log in
Hello. Thank you and Happy New Year.
Try setting schema : true in the model parameters.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question