在Mongo中将位置运算符与两级层次结构一起使用 [英] Using positional operator with two-level hierarchies in Mongo
本文介绍了在Mongo中将位置运算符与两级层次结构一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的层次结构为posts -> comments -> votes
.
如何更新对特定评论的特定投票?
要发表评论,它是comments.$
,但是我显然不能做comments.$.votes.$
.
How do I update a certain vote on certain comment?
For comment it is comments.$
, but I obviously can't do comments.$.votes.$
.
推荐答案
您目前无法做到(有这样的文章.
You cann't do it right now(there is such bug in jira). But i suppose you can update using server side side javascript. Check this article for more details.
以另一种方式将您的数据库方案重新设计到一个更高的层次,例如在post-> comments->表决将注释(甚至表决)移动到单独集合中的情况下.
Another way it redesign your db scheme to one level deep, for example in case of post-> comments-> votes move comments(or even votes) in separate collection.
这篇关于在Mongo中将位置运算符与两级层次结构一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文