Adding GeometryCollections with Mongoose Adding GeometryCollections with Mongoose mongoose mongoose

Adding GeometryCollections with Mongoose


The proper way is to split this into multiple schemas, which is much easier to read, use and maintain. For example:

GeoJSON.FeatureCollection = {    "type"  : {        "type": String,        "default": "FeatureCollection"    },    "features": [GeoJSON.Feature]}GeoJSON.Feature = {    "id": {        "type": "String"    },    "type": {        "type": String,        "default": "Feature"    },    "properties": {        "type": "Object"    },    "geometry": GeoJSON.Geometry}GeoJSON.GeometryCollection = {    "type": {        "type": String,        "default": "GeometryCollection"    },    "geometries": [GeoJSON.Geometry]}GeoJSON.Geometry = {    "type": {        "type": String,        "enum": [            "Point",            "MultiPoint",            "LineString",            "MultiLineString",            "Polygon",            "MultiPolygon"        ]    },    "coordinates": []}

Taken from: https://github.com/RideAmigosCorp/mongoose-geojson-schema