Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js mongoose临时文档的正确模式_Node.js_Mongodb_Mongoose_Nosql - Fatal编程技术网

Node.js mongoose临时文档的正确模式

Node.js mongoose临时文档的正确模式,node.js,mongodb,mongoose,nosql,Node.js,Mongodb,Mongoose,Nosql,我得到了以下猫鼬模型:文章和评论。 一篇文章引用了许多评论。现在,我希望能够在新的(待定的)文章和评论进入文章和评论集合之前查看它们。因此,我为挂起的版本创建了额外的集合: var PendingArticle = mongoose.model('Article', 'pendingArticles'); var PendingComment = mongoose.model('Comment',"pendingComment"); 一切都很顺利。但是现在,当我尝试填充PendingArtic

我得到了以下猫鼬模型:文章和评论。 一篇文章引用了许多评论。现在,我希望能够在新的(待定的)文章和评论进入文章和评论集合之前查看它们。因此,我为挂起的版本创建了额外的集合:

var PendingArticle = mongoose.model('Article', 'pendingArticles');
var PendingComment = mongoose.model('Comment',"pendingComment");
一切都很顺利。但是现在,当我尝试填充PendingArticle的注释时,找不到任何注释。我假设是因为它是从comments集合而不是pendingComments填充的。我真的需要单独的模式来完成吗

PendingArticle.find().populate('comments') ...

我的错误在哪里?我该怎么办?谢谢:)

为什么不在模式中使用可以更新的“pending[true/false]”属性,而不是创建新的模式?使用此属性,您可以决定发布(更新为true)或删除数据或。。。[其他逻辑]。这个额外表格背后的想法是,可能会有许多待处理的文章。前端需要经常查询文章表。所以我不想在查询许多不需要的文章时降低性能。