Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom attributes for 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!

like image 398
Aidan Feldman Avatar asked Dec 29 '10 18:12

Aidan Feldman


1 Answers

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"
    }
  }
}
like image 157
Jason Davies Avatar answered Sep 19 '22 03:09

Jason Davies