You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by faust 1111 <fa...@gmail.com> on 2010/04/29 19:37:44 UTC
Two kinds of Attachments in doc
Hi guy's
I need modeling this:
Audio
has_attachment
cover_img
trac_mp3
{
_attachments: {
'super_cover.png': {content_type: ''},
'my_track.mp3': {}
}
}
how later i can identify, which file is cover and which is track?
Now i have only this idea:
store file name in additional field cover_attach_name, trac_attach_name.
But may be another way?
Re: Two kinds of Attachments in doc
Posted by Anh <7z...@gmail.com>.
Your first approach would work, or you could also create an additional
document for one attachment, which has a "type" property.
For example:
{
"_id": "mytrack.mp3"
"_attachments": {
"file": {content_type: ''}
}
}
{
"_id": "super_cover.png",
"song": "mytrack.mp3"
"type": "cover",
"_attachments": {
"file": {content_type: ''}
}
}
"Splitting" it like this may offer some additional flexibility for views, etc.
Hard to say without knowing the use-cases better.
Hope this helps.
On Thu, Apr 29, 2010 at 11:11 AM, faust 1111 <fa...@gmail.com> wrote:
> It's not simple to me,
> to get url for attach i must parse _attachments.each.content_type == /^image/
>
>
>
> 2010/4/29 Randall Leeds <ra...@gmail.com>:
>> content_type starts with image/ it's the cover, if it starts with
>> audio/ it's the track?
>>
>> On Thu, Apr 29, 2010 at 10:37, faust 1111 <fa...@gmail.com> wrote:
>>> Hi guy's
>>>
>>> I need modeling this:
>>>
>>> Audio
>>> has_attachment
>>> cover_img
>>> trac_mp3
>>>
>>> {
>>> _attachments: {
>>> 'super_cover.png': {content_type: ''},
>>> 'my_track.mp3': {}
>>> }
>>> }
>>>
>>> how later i can identify, which file is cover and which is track?
>>> Now i have only this idea:
>>> store file name in additional field cover_attach_name, trac_attach_name.
>>>
>>> But may be another way?
>>>
>>
>
Re: Two kinds of Attachments in doc
Posted by faust 1111 <fa...@gmail.com>.
It's not simple to me,
to get url for attach i must parse _attachments.each.content_type == /^image/
2010/4/29 Randall Leeds <ra...@gmail.com>:
> content_type starts with image/ it's the cover, if it starts with
> audio/ it's the track?
>
> On Thu, Apr 29, 2010 at 10:37, faust 1111 <fa...@gmail.com> wrote:
>> Hi guy's
>>
>> I need modeling this:
>>
>> Audio
>> has_attachment
>> cover_img
>> trac_mp3
>>
>> {
>> _attachments: {
>> 'super_cover.png': {content_type: ''},
>> 'my_track.mp3': {}
>> }
>> }
>>
>> how later i can identify, which file is cover and which is track?
>> Now i have only this idea:
>> store file name in additional field cover_attach_name, trac_attach_name.
>>
>> But may be another way?
>>
>
Re: Two kinds of Attachments in doc
Posted by Randall Leeds <ra...@gmail.com>.
content_type starts with image/ it's the cover, if it starts with
audio/ it's the track?
On Thu, Apr 29, 2010 at 10:37, faust 1111 <fa...@gmail.com> wrote:
> Hi guy's
>
> I need modeling this:
>
> Audio
> has_attachment
> cover_img
> trac_mp3
>
> {
> _attachments: {
> 'super_cover.png': {content_type: ''},
> 'my_track.mp3': {}
> }
> }
>
> how later i can identify, which file is cover and which is track?
> Now i have only this idea:
> store file name in additional field cover_attach_name, trac_attach_name.
>
> But may be another way?
>