cnode社区源码修改的问题
发布于 7 年前 作者 xnbbosco 3237 次浏览 来自 问答

我想在原cnode社区增加类似于朋友圈的话题功能,查询完话题数据,作者数据,回复数据,点赞数据后,想把这几个数据拼接起来发给客户端。 当单独打印post.author的时候,是有数据的,但打印整个post的时候,就没有了author的数据,用curl测试返回的数据缺失没有author的内容,如下: untitled7.png

untitled8.png

untitled9.png

4 回复

有分享板块了 <br>来自<a href=“https://lzxb.github.io/vue-cnode/” target="_blank">vue-cnode手机版</a>

@1340641314 你是说手机版本有分享功能了?

应该是你查询返回的是一个mongoose对象 可以这样子改下 1.post = post.toObject();

或者查询的时候

Model.find().lean().exec(function (err, docs) {
  docs[0] instanceof mongoose.Document // false
});

或者

Model.findOne({}, null, { lean: true }, callback);

http://mongoosejs.com/docs/api.html#query_Query-lean

@xnbbosco 发帖,不是可以选择分享么 <br>来自<a href=“https://lzxb.github.io/vue-cnode/” target="_blank">vue-cnode手机版</a>

回到顶部