"Find" event handler not returning custom data
I'm trying to attach a property to a model when an instance of that model is requested from the database. I've set up two event handlers, afterFind() and afterFindById(), in order to cover models requested individually or in bulk.
I run a calculation based on properties within the model and then attach a "status" parameter. This works great for the beforeFindById handler:
However, when I move this over to afterFind, it doesn't work.
I can see in my console that this event is handled by CodeRunner...
...but I still get the standard response from Backendless.
I've also tried returning the data in the same format as it comes back in the response:
But this also doesn't seem to work, I still get the standard response (and a notification that my handler was called in the CodeRunner console).
If anyone has experienced this, I'd be appreciative to hear how you solved it.
Also, to the devs: the documentation on this seems to be broken. See "Find" section on this page:
I can't seem to find documentation on quirks like this, nor robust examples to follow that would indicate how problems like this are solved. The JS-Examples repository (https://github.com/Backendless/JS-Examples) seems to be all client-based. JS-Code-Runner repository (https://github.com/Backendless/JS-Code-Runner/blob/master/examples/handlers/) shows some examples for creation of objects, but not for finding objects. Perhaps I am missing some area of the docs that would better cover issues like this?