相关疑难解决方法(0)

将Mongoose docs转换为json

我以这种方式将jongoose docs作为json返回:

UserModel.find({}, function (err, users) {
    return res.end(JSON.stringify(users));
}
Run Code Online (Sandbox Code Playgroud)

但是,用户.__ proto__也被退回了.没有它我怎么能回来?我尝试了这个,但没有奏效:

UserModel.find({}, function (err, users) {
    return res.end(users.toJSON());    // has no method 'toJSON'
}
Run Code Online (Sandbox Code Playgroud)

json document object mongoose node.js

63
推荐指数
5
解决办法
9万
查看次数

标签 统计

document ×1

json ×1

mongoose ×1

node.js ×1

object ×1