I have the following schemes; An address is a geocoded location, and the Agency has many addresses. My question is: if I want to be able to perform a geospatial search on the agency based on its addresses, do I need to somehow index them at the agency level (already indexed at the address scheme level)?
In addition, I find it difficult to find information on how to find based on attached documents. In this case, is it possible to do what I hope for, or do I need to expand my domain structure a bit and have "AgencyAddress"? This approach seems a little DBMS for me, but I also see its advantages.
I'm a little confused about how to use ObjectId refs from an agency (or a BridgeAdAdressress object) without an inverted link from an address. I do not want to have backlinks, because the address will be used by a number of other objects in the application.
Thanks!
var AddressSchema = new Schema({ name : {type: String, default : ''}, street1 : {type: String, default : ''}, street2 : {type: String, default : ''}, city : {type: String, default : '', required: true}, state : {type: String, required : true}, zip : {type: String, default ''}, country : {type: String}, location : {longitude: Number, latitude:Number} type : {type: String, enum:['agent', 'agency', 'registrant'], index:true} created_at : {type: Date, default: Date.now}, updated_at : {type: Date, default: Date.now} primary : {type: Boolean, default: false} }); AddressSchema.index({location: '2d'});
Agency:
var AgencySchema = new Schema({ name : {type : String, default : '', required : true}, Type : {type : String, enum['medical', 'disaster-service', 'local-law', 'state-law', 'federal-law'], index:true}, Addresses : [Address], created_at : {type : Date, default : Date.now}, updated_at : {type : Date, default : Date.now} });