-
Notifications
You must be signed in to change notification settings - Fork 25
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
nullable field #20
Comments
I believe the preferred approach would be deleting the property from the containing object rather than setting it as null. If it's null it'll think there's an object to be cast/validated. |
Well that works, but an EDIT: plus
Yeah, that's it, I think one would want to cast null as a geojson polygon (json-type null is ok, plus it works with |
If you cast null as an empty GeoJSON object then it's going to want coordinate values, and if those are empty any geospatial index you have on Mongo will fail AFAIK. If the property doesn't exist it will simply be absented from the index. |
Actually they are sparse by default, and null is ok with sparse indexes. |
Ok I'll need to check and write a test for this. Thanks for bringing it to my attention. Obviously my knowledge of the Mongo API is a bit rusty! |
@cyrilchapon I know this is late, but could you give me an example of the schema and data that you were working with? It would be nice to get this working properly with systems requiring sparse indexes. |
When updating a document with a mongoose geojson schema, and trying to set it to null, when
required: false
, I'm getting :The text was updated successfully, but these errors were encountered: