CouchDB附件的自定义属性

Aid*_*man 7 couchdb attachment

我试图在单个CouchDB文档中存储多个独立附件,并为每个附件分配任意属性(即描述).这样做会有约定吗?据我所知,我不能_attachments直接在结构中插入它们.提前致谢!

Jas*_*ies 8

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

{
  "_attachments": {
    "foo.bar": ...,
    "xxx.yyy": ...
  },
  "attachment_attributes": {
    "foo.bar": {
      "description": "blah blah"
    },
    "xxx.yyy": {
      "description": "blah blah"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)