Closed ggarcia92 closed 6 years ago
Hi,
I am using this module and when I tried to create an Object Sails send me back ("Type mismatch for attribute to update")
This is my code: Model:
module.exports = { attributes: { id:{ type: 'string', primaryKey: 'range' }, picture:{ type: "string", required: true }, title:{ type: "string", required: true }, subcategories:{ collection: 'Subcategory', via: 'category_ref' }, user_ref:{ model: 'User' } } };
Controller:
create: function (req, res, next) { let name = "sometext"; var obj = { id: new String(uuidv4()), picture: name, title: req.param('title') } Category.create(obj, function (err, cat) { if (err) { return next(err); } else { return res.send(cat); } }); }); },
I verified with an instanceof and it is an String.
instanceof
My Sails version is 0.12.14.
Thanks in advance
I solved the problem casting req.param(title) to string like this String(req.param(title)). Also I needed to delete old local database after model changes.
req.param(title)
String(req.param(title))
Hi,
I am using this module and when I tried to create an Object Sails send me back ("Type mismatch for attribute to update")
This is my code: Model:
Controller:
I verified with an
instanceof
and it is an String.My Sails version is 0.12.14.
Thanks in advance