刚刚感受到CouchDB并且遇到一些误解。
我可以列出视图中的记录(感谢之前的响应者)
http://mysite.iriscouch.com/mydb/_design/_view/myview我修改了我的视图以包含_attachments,但这似乎没有显示_attachments,它们是jpeg文件。
map function(doc) { if(doc.SignMark && doc.Details) { emit(doc.SignMark, doc.Details, doc._attachments); } }我显然错过了一些简单的概念
谢谢 - mcl
Just getting a feel for CouchDB and hitting a few misunderstanding.
I can list the records from a view with (thanks to a previous responder)
http://mysite.iriscouch.com/mydb/_design/_view/myviewI have amended my view to include _attachments, but that does not appear to be showing the _attachments, which are jpeg files.
map function(doc) { if(doc.SignMark && doc.Details) { emit(doc.SignMark, doc.Details, doc._attachments); } }I have obviously missed some simple concept
Thanks - mcl
最满意答案
Emit总是有两个参数:键和值。 每个都可以是一个对象。 这样可行:
function(doc) { if(doc.SignMark && doc.Details) { emit(doc.SignMark, [doc.Details, doc._attachments]); } }但是您可以构造要发出的任意键和值,并且您还可以为每个文档发出多个或根本没有值。
优秀的CouchDB Book帮了我很多忙! 这是观点的相关章节: http : //guide.couchdb.org/draft/views.html
Emit always takes two parameters: key and value. Each can be an object. So this would work:
function(doc) { if(doc.SignMark && doc.Details) { emit(doc.SignMark, [doc.Details, doc._attachments]); } }But you can construct arbitrary keys and values to emit, and you can also emit multiple or no values at all for each document.
The excellent CouchDB Book helped me a lot! This is the relevant chapter for views: http://guide.couchdb.org/draft/views.html
更多推荐
发布评论