Giter VIP home page Giter VIP logo

Comments (7)

markstos avatar markstos commented on June 16, 2024

Thanks for the feedback.

What versions of Mongoose and Mongo DB are you using this with?

from mongoose-geojson-schema.

heatmonkey avatar heatmonkey commented on June 16, 2024

Mongoose is 3.8.8 and Mongo is 2.6

from mongoose-geojson-schema.

heatmonkey avatar heatmonkey commented on June 16, 2024

I put in a pull request that fixes it on my system.

from mongoose-geojson-schema.

markstos avatar markstos commented on June 16, 2024

I'm noting that this was the meat of the proposed update. I'm not crazy about it because while it solved the issue at hand, it weakened validation. I'd like to keep some stricter validation if possible while also addressing the issue.

diff --git a/GeoJSON.js b/GeoJSON.js
index 7423733..a054818 100644
--- a/GeoJSON.js
+++ b/GeoJSON.js
@@ -14,32 +14,32 @@ module.exports = GeoJSON = {};

 GeoJSON.Geometry = {
    'type': { type: String, required: true, enum: ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon"] },
-   coordinates: [Object]
+   coordinates: []
 }

 GeoJSON.Point = {
    'type': { type: String, required: true, default: "Point" },
-   coordinates: [Number]
+   coordinates: []
 };

 GeoJSON.MultiPoint = {
    'type': { type: String, required: true, default: "MultiPoint" },
-   coordinates: [Array]
+   coordinates: []
 };

 GeoJSON.MultiLineString = {
    'type': { type: String, required: true, default: "MultiLineString" },
-   coordinates: [Array]
+   coordinates: []
 }

 GeoJSON.Polygon = {
    'type': { type: String, required: true, default: "Polygon" },
-   coordinates: [Array]
+   coordinates: []
 };

 GeoJSON.MultiPolygon = {
    'type': { type: String, required: true, default: "MultiPolygon" },
-   coordinates: [Array]
+   coordinates: []
 };

 GeoJSON.GeometryCollection = {

from mongoose-geojson-schema.

mmacmillan avatar mmacmillan commented on June 16, 2024

@markstos mongoose 4.0.3, mongodb 2.6.9...still experiencing this issue. The fix to allow validation would to use the Schema.Types from mongoose, which would require adding that dependency. Without, we have to use an empty array, which falls back on a Mixed type. Will you accept a pull request that essentially does what @heatmonkey proposed, or do you have another fix for this issue?

from mongoose-geojson-schema.

markstos avatar markstos commented on June 16, 2024

@mmacmillan I don't mind adding a dependency, if we can fix this and still have validation.

I don't have an alternate fix for this.

from mongoose-geojson-schema.

markstos avatar markstos commented on June 16, 2024

This should be fixed by the 1.0.0 release, thanks to @joshkopecek

Notice the syntax is slightly different, so it's not a drop-in upgrade.

Re-open if you still see an issue with the 1.0 release.

from mongoose-geojson-schema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.