Delete some property of the request body doesn't work
I tried the next sentences and no work ("grant" is the property I'm trying delete)
User.beforeRemote('prototype.__create__guides', function(ctx, user, next) {
...
// I tried these
delete ctx.req.body.grant; // not working
delete ctx.args.data.grant; // not working
...
http.IncomingMessage fields are not processed in the data model phase (to do that it should be done at middleware level).
It works with the following (note that using I'm lodash to clone and omit certain properties):
User.beforeRemote('prototype.__create__guides', function (ctx, user, next) {
ctx.args.data = _.omit(ctx.args.data, 'grant')
next()
})
@onnoll Hav eyou tried @h2non's solution? Is this issue good to close?
I have the same issue, @h2non solution didn't work for me.
Edit:
This did the trick: ctx.args.data.myProperty = undefined;
When create related model, ctx.args.data is a model instance. For delete property use modelInstance.unsetAttribute(propertyName) Example: var guides = ctx.args.data guides.unsetAttribute('grant').
@Nivl @h2non @onnoll added example in previous comment. See this for more informations.
Are you guys still running into this issue? Can I close this?
@mrbatista solution was good for me.
Cool. Gonna close this. Please open a new issue if you are still running into problems.