{"action":"opened","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/1162","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/1162/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1162/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/1162/events","html_url":"https://github.com/strongloop/loopback/issues/1162","id":59785054,"number":1162,"title":"Hooks: Unable to delete a context.instance property","user":{"login":"PuKoren","id":4202557,"avatar_url":"https://avatars.githubusercontent.com/u/4202557?v=3","gravatar_id":"","url":"https://api.github.com/users/PuKoren","html_url":"https://github.com/PuKoren","followers_url":"https://api.github.com/users/PuKoren/followers","following_url":"https://api.github.com/users/PuKoren/following{/other_user}","gists_url":"https://api.github.com/users/PuKoren/gists{/gist_id}","starred_url":"https://api.github.com/users/PuKoren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PuKoren/subscriptions","organizations_url":"https://api.github.com/users/PuKoren/orgs","repos_url":"https://api.github.com/users/PuKoren/repos","events_url":"https://api.github.com/users/PuKoren/events{/privacy}","received_events_url":"https://api.github.com/users/PuKoren/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-04T11:25:50Z","updated_at":"2015-03-04T11:25:50Z","closed_at":null,"body":"I try to clean up some data after processing it into my context object, using:\r\n\r\nLet's say ctx.instance contains the following:\r\n```js\r\n{\r\n  unwantedProperty: \"MY_SUPER_MESSAGE\",\r\n  something: \"ok\",\r\n  anotherThing: \"not ok\"\r\n}\r\n```\r\n\r\n```js\r\nMyModel.observe('before save', function doSomethingOnDB(ctx, next) {\r\n  if (ctx.instance) {\r\n    //do something on insert, like filling another DB or calling a webservice\r\n    //then delete not wanted properties so they are not stored in my DB\r\n    ctx.instance.unwantedField = undefined;\r\n    //tried delete either\r\n    delete ctx.instance.unwantedField;\r\n  }\r\n  next();\r\n});\r\n```\r\n\r\nBut it appears that ```ctx.instance.unwantedField``` is stored in my DB anyway with value ```\"MY_SUPER_MESSAGE\"```\r\nSetting it to null insert it with null value, but I have no way to completely remove it and prevent insertion into the database.\r\n"}}