Comments (6)
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.
from mongoose-geojson-schema.
I believe the preferred approach would be deleting the property from the containing object rather than setting it as null.
Well that works, but an $unset
field doesn't mean the same as a null
field.
null
is for deliberate absence of value, not set rather means not-really-wanted absence of value.
EDIT: plus
If it's null it'll think there's an object to be cast/validated.
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 Object
)
from mongoose-geojson-schema.
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.
from mongoose-geojson-schema.
any geospatial index you have on Mongo will fail AFAIK
Actually they are sparse by default, and null is ok with sparse indexes.
from mongoose-geojson-schema.
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!
from mongoose-geojson-schema.
@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.
from mongoose-geojson-schema.
Related Issues (20)
- CastError surfacing still an issue HOT 3
- Can't use $geoIntersects HOT 1
- Correct way to 2dsphere index when using these schema
- Can't query using `$nearSphere` because of model validation of query object HOT 2
- Add "schemaName" to each of the SchemaTypes HOT 1
- Typeerror: GeoJSON is not a constructor HOT 1
- The cast function doesn't take JSON into consideration HOT 2
- Cannot create type point with point array HOT 2
- Typescript definition HOT 4
- Does not work with mongoose 5.x HOT 1
- Failing to validate a GeometryCollection inside a Feature HOT 4
- add pure export
- Passing NaN as point coordinates should fail HOT 6
- Conflicts on typescript compile HOT 2
- Remove `@types/mongoose` dependency HOT 1
- Feature.properties should be mandatory HOT 2
- Open to PRs? HOT 30
- specific errors are not available when validation fails HOT 1
- GeoJSON type HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose-geojson-schema.