Closed fabioespinosa closed 7 years ago
You need to define the id in the schema.
On Wed, Jan 25, 2017, 10:54 Fabio Espinosa notifications@github.com wrote:
Bug report
When having the option of {enforce_extra: "remove"} in the createModel method, one cannot access an id of a just saved object.
I checked with {enforce_extra: "strict"} and it works fine, but not with "remove" option. I figured it must be a bug then.
Look at the following example:
var Post = thinky.createModel('Post', { content: type.string() }, {enforce_extra: "remove"});
exports.add = (req, res) => { var post = new Post(req.body); post.save().then(result => {
// I need the id of the newly created post so I can return it back
// But with "remove" option on the schema it results in undefined req.params.idPost = post.id; module.exports.get(req, res);
}).error(err => { console.log(err); res.status(500); res.send(); }); }
I can find a workaroung using strict, however it would be amazing if someone can correct this bug.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/neumino/thinky/issues/604, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZOu-9b1OHWlxmhTm8GBJ-0vYJBKjucks5rV5pugaJpZM4Lt297 .
Thanks @neumino worked like a charm
Bug report
When having the option of {enforce_extra: "remove"} in the createModel method, one cannot access an id of a just saved object.
I checked with {enforce_extra: "strict"} and it works fine, but not with "remove" option. I figured it must be a bug then.
Look at the following example:
I can find a workaroung using strict, however it would be amazing if someone can correct this bug.