经过多年的 MySQL 之后,CouchDB 的新手。为什么我在返回所有记录的视图中的值映射中获取元数据 _id 和 _rev?这是我的看法:
"views": "{
"all": "{
"map": "function (doc) {
emit(doc.date, doc)
}"
}"
}"
当我查询 /database/_design/id/_view/all 时,我得到以下 JSON:
{"total_rows":2,"offset":0,"rows":[
{"id":"b77bbd5ab73b809ca830fe4b6900506f","key":"[2013, 09, 21, 00, 00, 00]","value":{"_id":"b77bbd5ab73b809ca830fe4b6900506f","_rev":"11-b134dfe46f86c96b4f7e2cf0abb13b61","location":"Mesuk Market","product":"Traditional Pork Skewer","total_items":550,"created_at":"[2013, 09, 21, 23, 24, 06]","date":"[2013, 09, 21, 00, 00, 00]"}},
{"id":"b77bbd5ab73b809ca830fe4b69005f1e","key":"[2013, 09, 21, 00, 00, 00]","value":{"_id":"b77bbd5ab73b809ca830fe4b69005f1e","_rev":"2-ee4e464cdf5de23563c0cc6b62bc4b07","date":"[2013, 09, 21, 00, 00, 00]","created_at":"[2013, 09, 21, 23, 27, 00]","total_items":100,"product":"All Meat Skewer","location":"Mesuk Market"}}
]}
为什么我在值映射中得到 _id 和 _rev?这里的文档(和其他几个地方)没有在值中显示这些字段。
这并没有真正阻碍我在项目上的工作,但我不明白为什么会这样。是来自我设置视图或进行查询的方式吗?