CouchDB附件的自定义属性 [英] Custom attributes for CouchDB attachments

查看:47
本文介绍了CouchDB附件的自定义属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在一个CouchDB文档中存储多个独立附件,并为每个附件分配任意属性(即描述).是否有执行此操作的约定?据我所知,我无法将它们直接插入到_attachments结构中.预先感谢!

I am trying to store multiple standalone attachments in a single CouchDB document, and assign arbitrary attributes (i.e. description) to each one. Is there a convention for doing this? From what I can tell, I cannot insert them in the _attachments structure directly. Thanks in advance!

推荐答案

您不能直接在_attachments中进行任何修改,因为它保留供CouchDB使用.但是,使用与_attachments中相同的键(附件名称)将任意属性存储在诸如attachment_attributes之类的成员中是非常合理的.例如:

You can't modify anything in _attachments directly as it is reserved for use by CouchDB. However, it would be quite reasonable to store arbitrary attributes in a member such as attachment_attributes, using the same keys as in _attachments (the attachment names). For example:

{
  "_attachments": {
    "foo.bar": ...,
    "xxx.yyy": ...
  },
  "attachment_attributes": {
    "foo.bar": {
      "description": "blah blah"
    },
    "xxx.yyy": {
      "description": "blah blah"
    }
  }
}

这篇关于CouchDB附件的自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆