相关疑难解决方法(0)

猫鼬和浮动值

我的lat&lng数字正在转换为字符串.我的部分整数仍然是Number的正确数据类型.如何设置模型以便我可以将我的lat&lng作为Float而不是String返回?

我在我的数据库中存储latLng数据.现在我将我的数据类型设置为Lat和lng的数字.当我检查我的数据库时,我看到了这个:

{
  "_id" : ObjectId("563bd98a105249f325bb8a7e"),
  "lat" : 41.8126189999999980,
  "lng" : -87.8187850000000054,
  "created" : ISODate("2015-11-05T22:34:50.511Z"),
  "__v" : 0,
  "section" : 0,
}
Run Code Online (Sandbox Code Playgroud)

但是当我使用快递我的数据时,我得到了这个:

{
  "_id": "563bd98a105249f325bb8a7e",
  "lat" : "41.8126189999999980",
  "lng" : "-87.8187850000000054",
  "__v": 0,
  "section" : 0,
  "created" : "2015-11-05T22:34:50.511Z",
}
Run Code Online (Sandbox Code Playgroud)

我的模特:

var WaypointSchema = new Schema({
    lat: {
        type: Number
    },
    lng: {
        type: Number
    },
    section: {
        type: Number
    }
    created: {
        type: Date,
        default: Date.now

    }
});

mongoose.model('Waypoint', WaypointSchema);
Run Code Online (Sandbox Code Playgroud)

快速控制器:

exports.list = function(req, res) { 
    Waypoint.find().sort('-created').populate('user', 'displayName').exec(function(err, …
Run Code Online (Sandbox Code Playgroud)

mongodb node.js express meanjs

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

express ×1

meanjs ×1

mongodb ×1

node.js ×1