Reputation: 3665
I would need to have something like this
{
event : "something",
location : [
{
long:25, lat:34
}.
}
long:25, lat:35
}.
.
.
.
]
}
Is this possible? And is it possible to have a geospatial index for the location field? I would have queries with $nearSphere.
Thanks
EDIT: mongoose schema question
having the schema entry be something like location : [{ lon : Number, lat: Number}] gets me to end up with an aditional _id for each object in the location array. Is that 1. a problem? 2. a nuissance? 3. something that i can fix?
ex : { "lon":1, "lat":2, "_id":"50bfeea2a3092d1d67000007" },
Upvotes: 0
Views: 613
Reputation: 311835
If you don't want each of the location
elements to have an _id
field, you can disable that by explicitly defining a schema for the elements with the _id
option set to false
.
Like this:
var testSchema = new mongoose.Schema({
event: String,
location: [new Schema({long: Number, lat: Number}, {_id: false})]
});
Upvotes: 2