Mongodb mongo db使用相同的id从两个表中获取数据
我有两个表Mongodb mongo db使用相同的id从两个表中获取数据,mongodb,Mongodb,我有两个表history和jobs 我的历史记录表包含 > db.history.find() { "id" : "21", "browser" : "FF","os" : "Windows" "datetime" : "2013-11-26 17:04:21", "_id" : ObjectId("5294873d6b441e2c16000002") } db.jobs.find() { "_id" : ObjectId("5289c147db9ed2b022f95a36"), "
history
和jobs
我的历史记录表包含
> db.history.find()
{ "id" : "21", "browser" : "FF","os" : "Windows" "datetime" : "2013-11-26 17:04:21", "_id" : ObjectId("5294873d6b441e2c16000002") }
db.jobs.find()
{ "_id" : ObjectId("5289c147db9ed2b022f95a36"), "id" : "21", "launch" : "ertret", "names" : "234", "script" : "art-pagination" }
从以上两个表中,我需要使用commonid:21获得browser
、launch
、script
和os
这是如何可能的。您可以使用以下两个查询来实现。单次查询不可能得到它
> db.history.find({'id':21}, {'browser':1, 'os':1})
> db.jobs.find({'id':21}, {'launch':1,'script':1 })
它不是命名表,而是MongoDB=P中的集合