【发布时间】:2015-03-25 11:32:19
【问题描述】:
我有两个系列,商场和商店。我想保留它们的位置信息(如纬度和经度)。对于商场来说,这很容易,因为它们只有一个位置信息,所以我可以定义纬度和经度属性。但对于商店来说,它们可以在商场内或街道上,并且有多个位置。我想保持商店和商场之间的关系,因为它们在商场内的地方。我想将位置保留为单独的集合(至少对于商店而言),否则当我列出商店时数据会非常繁重。仅在必要时才会显示(下载)所选商店的位置。所以问题是,位置收集的数据模型应该如何?我正在考虑这样的事情,但我觉得这不是最好的主意。为了简单起见,我考虑将 mall 的 lat、lan 数据直接保存在其集合中(顺便说一句,我使用简单的模式):
ShopLocations = new Mongo.Collection('shoplocations');
var shopsLocationsSchema = new SimpleSchema ({
name: {
type: String,
label: 'Location Name',
max: 200
},
inMall: {
type: Boolean,
label: 'Is it in the mall?',
optional: true
},
mallId: {
type: String,
label: 'Mall ID',
optional: true
},
latitude: {
type: Number,
label: 'Latitude',
decimal: true,
optional: true
},
longitude: {
type: Number,
label: 'Latitude',
decimal: true,
optional: true
}
});
ShopLocations.attachSchema(shopsLocationsSchema, {replace: true});
【问题讨论】:
标签: javascript meteor datamodel