You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Adam Wolff <aw...@gmail.com> on 2009/09/24 21:45:25 UTC

Multiple IDs for one document

Hi list,We have a little data modeling problem and I'm wondering there's a
pat solution for it.

We have documents that look like this: {
   ids : ["a", "b"],
   meta:{...}
}

In our system, a process can come along and need to add an id to the ids
list. The ids must be globally unique. The only solution we've thought of is
to give the meta information a uuid, and then write a bunch of documents,
like this:
a : <uuid>
b : <uuid>
<uuid> : {...meta...}

It's messy though, and the handling of write failures is tricky. Is there a
better way to do this that we're missing?

Thanks,
A

Re: Multiple IDs for one document

Posted by Chris Anderson <jc...@apache.org>.
On Thu, Sep 24, 2009 at 1:31 PM, Adam Wolff <aw...@gmail.com> wrote:
> We just thought of a funny alternative --- write every entity into one
> document. Not necessarily practical in every case, but it should work for
> us.
> A
>

That's the "right" way to do it.

> On Thu, Sep 24, 2009 at 1:07 PM, Benoit Chesneau <bc...@gmail.com>wrote:
>
>> On Thu, Sep 24, 2009 at 9:45 PM, Adam Wolff <aw...@gmail.com> wrote:
>> > Hi list,We have a little data modeling problem and I'm wondering there's
>> a
>> > pat solution for it.
>> >
>> > We have documents that look like this: {
>> >   ids : ["a", "b"],
>> >   meta:{...}
>> > }
>> >
>> > In our system, a process can come along and need to add an id to the ids
>> > list. The ids must be globally unique. The only solution we've thought of
>> is
>> > to give the meta information a uuid, and then write a bunch of documents,
>> > like this:
>> > a : <uuid>
>> > b : <uuid>
>> > <uuid> : {...meta...}
>> >
>> > It's messy though, and the handling of write failures is tricky. Is there
>> a
>> > better way to do this that we're missing?
>> >
>> > Thanks,
>> > A
>> >
>> You could emit the ids in a view and check for their existence before
>> it's written in the doc but then you will nto find a solution to lock
>> it until it's written.
>>
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: Multiple IDs for one document

Posted by Adam Wolff <aw...@gmail.com>.
We just thought of a funny alternative --- write every entity into one
document. Not necessarily practical in every case, but it should work for
us.
A

On Thu, Sep 24, 2009 at 1:07 PM, Benoit Chesneau <bc...@gmail.com>wrote:

> On Thu, Sep 24, 2009 at 9:45 PM, Adam Wolff <aw...@gmail.com> wrote:
> > Hi list,We have a little data modeling problem and I'm wondering there's
> a
> > pat solution for it.
> >
> > We have documents that look like this: {
> >   ids : ["a", "b"],
> >   meta:{...}
> > }
> >
> > In our system, a process can come along and need to add an id to the ids
> > list. The ids must be globally unique. The only solution we've thought of
> is
> > to give the meta information a uuid, and then write a bunch of documents,
> > like this:
> > a : <uuid>
> > b : <uuid>
> > <uuid> : {...meta...}
> >
> > It's messy though, and the handling of write failures is tricky. Is there
> a
> > better way to do this that we're missing?
> >
> > Thanks,
> > A
> >
> You could emit the ids in a view and check for their existence before
> it's written in the doc but then you will nto find a solution to lock
> it until it's written.
>

Re: Multiple IDs for one document

Posted by Benoit Chesneau <bc...@gmail.com>.
On Thu, Sep 24, 2009 at 9:45 PM, Adam Wolff <aw...@gmail.com> wrote:
> Hi list,We have a little data modeling problem and I'm wondering there's a
> pat solution for it.
>
> We have documents that look like this: {
>   ids : ["a", "b"],
>   meta:{...}
> }
>
> In our system, a process can come along and need to add an id to the ids
> list. The ids must be globally unique. The only solution we've thought of is
> to give the meta information a uuid, and then write a bunch of documents,
> like this:
> a : <uuid>
> b : <uuid>
> <uuid> : {...meta...}
>
> It's messy though, and the handling of write failures is tricky. Is there a
> better way to do this that we're missing?
>
> Thanks,
> A
>
You could emit the ids in a view and check for their existence before
it's written in the doc but then you will nto find a solution to lock
it until it's written.