Couchdb:显示_附件
只是了解一下 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/myview
I 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Emit 始终采用两个参数:键和值。每个都可以是一个对象。所以这可行:
但是您可以构造要发出的任意键和值,并且还可以为每个文档发出多个值或根本不发出值。
优秀的 CouchDB 书籍对我帮助很大!这是视图的相关章节: http://guide.couchdb.org/draft/views.html
Emit always takes two parameters: key and value. Each can be an object. So this would work:
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
从视图中您无法访问附件本身。您只能使用存储在 doc._attachments 中的元数据。
因此,根据您的要求,您必须使用 /db/doc-id/attachment-name.jpg 格式的第二个请求来访问实际附件
,或者,如果您要渲染为 html,则只需使用 src 构造一个图像标记='/db/doc-id/附件名称.jpg'
From within a view you cannot access the attachments themselves. You can only the metadata which is stored in the doc._attachments.
So depending on your requirements, you will have to access the actual attachment with a second request of the format /db/doc-id/attachment-name.jpg
or, if you are rendering to html, just construct an image tag with the src='/db/doc-id/attachment-name.jpg'