【发布时间】:2014-01-17 04:14:16
【问题描述】:
我在 mongodb 中有两个表的结构:
> db.mapping.find()
{ "_id" : ObjectId("52d74f4941538c0b386090af"),
"tc" : DBRef("fttc", ObjectId("52d74f4841538c0b3860902e")),
"hit" : { "24" : 1, "25" : 1, "26" : 1, "27" : 2}}
...
> db.fttc.find()
{ "_id" : ObjectId("52d74f4841538c0b38609041"),
"full" : "build1111_tastcase_20",
"tags" : [ "tag_0" ] }
...
> db.mapping.find()[0].tc.fetch().full
build1111_tastcase_1
> db.mapping.find({'tc.$id':ObjectId("52d74f4841538c0b3860902e")})
{ "_id" : ObjectId("52d74f4941538c0b386090a0"),
"tc" : DBRef("fttc", ObjectId("52d74f4841538c0b3860902e")),
"hit" : { "24" : 3, "25" : 3 } }
...
现在,我可以得到tc的属性'id'为ObjectId("52d74f4841538c0b3860902e")的物品了。
但是,我如何才能从 mapping 中找到 所有 项,其 tc 的属性 'full' 是 'build1111_tastcase_20强>' ?
有查询语句吗?
任何帮助或建议将不胜感激!
【问题讨论】: