Попробуйте создать схему mon goose, как показано ниже.
Это будет полезно для ваших требований
//Country Schema
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Country = new Schema({
CountryID: { type: String, default: "" },
Country_Name: { type: String, default: "" },
Country_Code: { type: String, default: "" },//Mobile
Country_Currency: { type: String, default: "" },//Business or Ecommerce
location: { //for Map Purpose
longitude: Number,
latitude: Number
},
Point: { type: [Number], index: '2d' },
}, { collection: 'Country' });
Country.index({ Point: '2dsphere' });
module.exports = mongoose.model('Country', Country);
//City Schema
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var City = new Schema({
CityID: { type: String, default: "" },
CountryID: { type: String, default: "" },
City_Name: { type: String, default: "" },
location: { //for Map Purpose
longitude: Number,
latitude: Number
},
Point: { type: [Number], index: '2d' },
}, { collection: 'City' });
City.index({ Point: '2dsphere' });
module.exports = mongoose.model('City', City);