在DBRef类型上的mongodb查询 [英] mongodb query on DBRef type
本文介绍了在DBRef类型上的mongodb查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在mongodb shell中的有效mongodb查询中打开此查询.
How do I turn this query in a valid mongodb Query in mongodb shell.
{ 'cars.owner.$ref' : 'users' }
cars.owner
是此处的DBRef,但$ref
无效
cars.owner
is a DBRef here, but $ref
is invalid
我收到此错误:
"$err" : "Positional operator does not match the query specifier."
我在这里的目的是弄清楚是否有其他收藏家和用户拥有"的汽车.
My objective here is to figure out if there are any cars "owned" by different collections then users.
推荐答案
<parameterName>: DBRef("CollectionName", "_id Value")
放入集合.然后创建一个以实名作为ParameterName的Bean,并放置morphia orm的@Reference批注,然后执行所需的操作
put in collection.Then Create a Bean having feild name as parameterName, and put @Reference annotation of morphia orm then do operations you want
这篇关于在DBRef类型上的mongodb查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文