【问题标题】:MongoDB schema : default coordinates for GPS positionMongoDB架构:GPS位置的默认坐标
【发布时间】:2016-09-03 09:02:39
【问题描述】:

我应该在尚未上传其位置的新创建的用户文档中插入什么 GPS 坐标?现在,我只是插入 0 和 0,因为插入像 'undefined' 这样的值会使数据库抛出一些错误......

这是我的架构:

var userSchema = new mongoose.Schema({
firstname: {
  type: String,
  required: true,
  unique: false
},
lastname: {
  type: String,
  required: true,
  unique: false
},
location: {
  'type': {
    type: String,
    required: true,
    enum: ['Point', 'LineString', 'Polygon'],
    default: 'Point'
  },
  coordinates: [Number],
  select: false
},

});

【问题讨论】:

    标签: node.js mongoose schema coordinates


    【解决方案1】:

    您可以使用任何魔法值,例如 0,0,也可以使用超出记录范围/边界的位置,例如珠穆朗玛峰、火山喷发地、南极等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-19
      • 1970-01-01
      相关资源
      最近更新 更多