I am using Objectionjs
In my Model, I have defined a password field.
I want to prevent this field from showing up for all queries - select, inserts, updates etc - that is, after making a query, I don't want this field to be present in the object returned
Is there a method on the model itself that I can use to do this or do I need to omit the field in each query that I make?
You can for example override $afterInsert
, $afterUpdate
, $afterGet
and make sure that fields are deleted in those hooks.
http://vincit.github.io/objection.js/#_s_afterinsert
If you just don't like that some fields are show when you are converting model to json, for example for returning model to client, then overriding $formatJson
might be enough.