On Jul 5, 2010, at 9:40 PM, Alex Yiu wrote:

> 
> 
> Hi, 
> 
> Option #1: really defeats the purpose of having nested JSON objects
> Option #3: Base64 encoding is not that efficient. Bloated ratio around 1.3x. 
> 
> I would consider option #2: if CouchDB has no intention to support this 
> feature, that is I will manually maintain the cross reference relationship 
> between the line and attachments. e.g. :
> 

I don't expect CouchDB will ever support a different JSON format / location for 
attachment stubs. what we have is enough to get the job done, and I think it's 
simpler for clients to know where to look for binary.

Chris

> [ { "line" : 1, "price": "33.4", "picture" : { "attachmentName" : "picX" } , 
> { "line": 2, ...  } ]
> "_attachments" : {
>  "picX" : ...,
>  ... 
> }
> 
> Similar to "id" and "ref" concepts. 
> 
> I would consider my proposal in my original email is a nice to have feature. 
> 
> 
> 
> Alex
> 
> 
> 
> 
> 
> ________________________________
> From: Anh <[email protected]>
> To: [email protected]
> Sent: Mon, July 5, 2010 9:14:04 PM
> Subject: Re: "_attachements" field name in CouchDB
> 
> Could you consider any of these 3 options?:
> 
> 1) A document per line item, and a single standard attachment name
> such as "picture"?
> 
> 2) A convention for attachments associated with a series of line items
> in a single doc, such that _attachments contains a corresponding
> series of attachments?  E.g.:
> 
> [ { "line" : 1, "price": "33.4" } , { "line": 2 } ]
> "_attachments" : {
>   "picture1" : ...,
>   "picture2" : ...,
> }
> 
> 3) Base64 the image into the "picture attachement" as text, and you
> handle the unencoding, etc.
> 
> 
> Hope this helps.
> 
> On Mon, Jul 5, 2010 at 8:36 PM, Alex Yiu <[email protected]> wrote:
>> 
>> 
>> Hi, all,
>> 
>> I am a newbie to CouchDB. Sorry for a potential newbie question.
>> 
>> I am wondering whether we can associate binary attachment to a field name 
>> defined by users, instead of the generic pre-defined "_attachments" field 
>> name? If we can do that, we can manage association between multiple 
>> attachments and different parts of the JSON document easier.
>> 
>> For example, if a JSON doc represents a purchase order, a PO can have 
>> multiple line items. Each line item may have optional attachment.
>> 
>> [ { "line" : 1, "price": "33.4", "picture attachement" : { ... } } , { 
>> "line": 2, ... } ]
>> 
>> Within the "picture attachement" object, it contains some special fields to 
>> denote it is an attachement.
>> e.g.  "picture attachement" : { "_attachment_id": "..." , ... }
>> 
>> We can do something to that extent already. That is great.
>> 
>> If not, do we have a JIRA issue for that already?
>> If we have not that JIRA issue yet, does it worth log an issue there now?
>> 
>> 
>> Thank you so much for answering this newbie question!!!
>> 
>> 
>> Alex Yiu
>> 
>> 
>> 
>> 
> 
> 
> 

Reply via email to