CouchDB 附件的自定义属性

发布于 2024-10-09 07:40:08 字数 113 浏览 0 评论 0原文

我试图在单个 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单调的奢华 2024-10-16 07:40:08

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

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

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"
    }
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文