-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Feature request: Optional ref properties #2285
Comments
I think this is a bug. The 2nd proposal should be working. |
I've looked into it and the validate plugin throws the error. RxDB itself might allow ref properties with value NULL, but is-my-json-valid does not, since the type does not specify NULL as well. And I assume that the other validate plugins act the same (although I haven't tested it yet), since that is the correct behavior accrording to JSONSchema. So the only solution I see is the 1st proposal. Or is there anything that can be said against that change? |
Closing this, PR is merged. Thank you. |
Case
Feature Request
Issue
We have a server-side data model with an optional foreign key. This property can either be a string referencing another collection or NULL. It is not possible to define this schema for rxdb.
Example
Let's say we have two classes, User and Car. Some users have cars, others don't. So the property user.car_id can either point to a car or be null.
A possible schema for User:
This schema will fail (e.g. during a migration) for any entry in the database with a car_id of NULL, since the schema does not allow for null values. It does not matter whether 'car_id' is a required property or not.
Possible resolutions
We hope for either:
The text was updated successfully, but these errors were encountered: