0
我在蒙戈數據庫的表中調用文件查詢的MongoDB與DBREF
{
"_id" : ObjectId("565a7f1"),
"_class" : "Document", "name" :
"Book Template",
"location" : "/Book Template.pdf",
"type" : DBRef("types", ObjectId("3eaabf5"))
},
{
"_id" : ObjectId("565a7f2),
"_class" : "Document",
"name" : "Sample Contract",
"location" : "/Sample Contract.pdf",
"type" : DBRef("types", ObjectId("3eaabf5"))
},
{
"_id" : ObjectId("565a7f3"),
"_class" : "Document",
"name" : "Clustering with RabbitMQ",
"location" : "/Clustering with RabbitMQ.txt",
"type" : DBRef("types", ObjectId("3eaabf6"))
}
,然後我也被稱爲表類型
{
"_id" : ObjectId("3eaabf5"),
"_class" : "Type",
"name" : "PDF",
"description" : "Portable Document Format",
"extension" : ".pdf"
};
{
"_id" : ObjectId("3eaabf6"),
"_class" : "Type",
"name" : "NOTE",
"description" : "Text Notes",
"extension" : ".txt"
},
{
"_id" : ObjectId("3eaabf7"),
"_class" : "Type",
"name" : "WEB",
"description" : "Web Link",
"extension" : ".url"
}
我要查詢的文件表裏面有所有的文件PDF的擴展。
所以我寫了下面的查詢......但一切都返回空結果。
>db.documents.find({"types.$id":"3eaabf5"})
>
>db.documents.find({"types.name":"PDF"})
>
OK ......但你也像'db.documents.find({ 「類型$名稱。」 類型的名稱查詢:」 PDF「})' –
不幸的是,你不能這樣做。 Mongodb不會自動解析DbRef。 – max