【发布时间】:2013-06-13 11:52:11
【问题描述】:
在 mongo shell 或 PHP 中 如何检索此文档的“列表”属性?
{
"_id" : ObjectId("51b972ebe4b075a9690bbc5b"),
"list" : [
"Environnement",
"Toutes thématiques",
"Transports"]
}
我正在寻找怎么做 db.tags.list 将返回 mycollection 中文档的所有“列表”属性
答案是: db.tags.findOne().list
【问题讨论】:
-
$doc['list']会做到的 -
是的,就像 Sammaye 说的那样......另外,如果你有一个更结构化的对象,你可以使用诸如 $doc["list.someotherstuff"] 之类的点来访问
-
db.collection.find({'willy': 'wonka'})[0].hat_color