You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, it is inconvenient when you want to restrict only a handful of columns/relations in a model with lots of columns. For instance, if we have a model with 20 columns and only want to restrict one column, currently, we have to list all 19 columns we want to allow
In certain cases, this might make more sense and can lead to concise code that is easier to follow and reason about.
Possible Solutions
There are a couple of ways this can be implemented
1. Add optional parameter in the allowAll method
An optional parameter can be added to specify exceptions
findQuery(User).allowAll(['password']).buid(query)// Allow all columns except password
2. Add disallow() method
A new method can be added to complement the allow method. This would be mutually exclusive and the opposite of the allow method
I had a scenario where it was easier to disallow a field or two instead of allowing. I'm using the jsonSchema property in my models so I simply created a helper function that reads the properties from the jsonSchema and then creates the allowed list by filtering out the disallowed properties.
The Problem
Currently, it is possible to limit columns/relations that can be filtered/ordered via the
allow
methodHowever, it is inconvenient when you want to restrict only a handful of columns/relations in a model with lots of columns. For instance, if we have a model with 20 columns and only want to restrict one column, currently, we have to list all 19 columns we want to allow
It would be more convenient if we could specify only the column we want to restrict instead
In certain cases, this might make more sense and can lead to concise code that is easier to follow and reason about.
Possible Solutions
There are a couple of ways this can be implemented
1. Add optional parameter in the allowAll method
An optional parameter can be added to specify exceptions
2. Add disallow() method
A new method can be added to complement the
allow
method. This would be mutually exclusive and the opposite of theallow
methodI am keen to know if this has been considered before
The text was updated successfully, but these errors were encountered: