-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preventChanges hook should support dot notation #728
Comments
Nice addition. I don't use dot-notation and I don't use mongo myself but I see the use case. But you maybe want to prevent changes for Also maybe you have a column with dot-notation. In postgres e.g. it's possible to define a column as 'quotas.members'. So you could have a column 'quotas' as integer and 'quotas.members' as integer in the same table. It's does not sound like a good design but it's possible. So for maximum flexibility you maybe should define it like this: before: {
patch: [preventChanges(true, [{ name: 'quotas', nested: true }])]
} where What do you think? |
For sure we could manage it this way but I am not able to get your point and if it's necessary:
As 1 and 2 are mutually exclusive I don't see the need to distinguish with a Another option is to be able to provide field names as a regex like this Yet, I wonder if we also need to support the following construct in Feathers for some adapters, which can make things harder as we need to 'dotify' the payload first: |
Steps to reproduce
Setup the hook like this on a service:
Expected behavior
If
quotas
is actually a nested object and I perform a patch like this using the mongo adapterservice.patch(id, { 'quotas.members': 200 })
, I expect the hook to raise an error.Actual behavior
The hook does not filter data properties targetting a prevented field when using dot notation, neither raises an error.
It is not necessarily a bug as one could probably avoid this by registering all available nested properties like this:
However, in some cases, it is not possible to know all properties upfront. Moreover, it seems to me a convenient way (or shortcut) to discard all properties of a nested object.
We implemented it on our side for now if it can help and seems relevent for this module as well. If so we could try to make a PR but welcome any feedback first.
The text was updated successfully, but these errors were encountered: