mongoose 定义经纬度数据类型
生活随笔
收集整理的這篇文章主要介紹了
mongoose 定义经纬度数据类型
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本來想用Double在mongoose中直接定義經緯度的。但是發現mongoose的數據類型只有下面幾種。
String Number Date Buffer Boolean Mixed ObjectId Array Decimal128 Map所以我們使用Decimal128來定義經緯度
const LocationsSchema = new mongoose.Schema({latitude: {type: mongoose.Schema.Types.Decimal128,required: true,},longitude: {type: mongoose.Schema.Types.Decimal128,required: true,} })總結
以上是生活随笔為你收集整理的mongoose 定义经纬度数据类型的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: navicat的安装
- 下一篇: 实验四 恶意代码