node.js - MongoDB 架构 : default coordinates for GPS position

标签 node.js mongoose schema coordinates

我应该将什么 GPS 坐标插入到新创建的尚未上传其位置的用户文档中?现在,我只是插入 0 和 0,因为插入“未定义”之类的值会使数据库抛出一些错误...

这是我的架构:

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
},

});

最佳答案

您可以使用任何魔法值,例如 0,0,也可以使用超出您录制的范围/界限的位置,例如珠穆朗玛峰的顶峰、火山的创造者、南极等。

关于node.js - MongoDB 架构 : default coordinates for GPS position,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37103716/

相关文章:

node.js - 从 postgis 格式化 geojson

javascript - Jest 测试 Mongoose 模型实例化

Node.js - 如何使用回调调用异步函数?

mysql - 为什么 "schema"在 MySQL 和 SQL Server 中不同?

schema - 如何设计HBase模式

c# - app.config configSections自定义设置找不到schema信息

javascript - 如何在 async.waterfall 中调用 Promise().then() 内的 cb()

mysql - Sequelize Join 非主键

node.js - 未找到 Mocha 测试 : "0 passing"

node.js - 如何用nodejs和mongoose查找文档,为什么没有结果?