You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Stanley Iriele <si...@gmail.com> on 2014/03/05 07:27:37 UTC

Storing a doc I'd as json array string

I want to store a document for a particular game... Version...and
key...where key could be any string. I want there to be a key collision on
insert

I don't want to make up some delimeter because that wouldn't go so well....
On a scale of 1 to 10 how bad of an idea is this?

Re: Storing a doc I'd as json array string

Posted by Jens Alfke <je...@couchbase.com>.
On Mar 5, 2014, at 3:18 AM, Robert Samuel Newson <rn...@apache.org> wrote:

> doc _ids have to be strings, you can’t use an array.

What Bob said.

You could always JSON-encode the array and use that string as the document ID. It’d be very ugly (especially when encoded in a URL!) but it would probably work.

Or you could concatenate the components using some delimiter character (that can’t appear in the components), the way everyone else does :)

—Jens

Re: Storing a doc I'd as json array string

Posted by Robert Samuel Newson <rn...@apache.org>.
doc _ids have to be strings, you can’t use an array.

B.

On 5 Mar 2014, at 06:27, Stanley Iriele <si...@gmail.com> wrote:

> I want to store a document for a particular game... Version...and
> key...where key could be any string. I want there to be a key collision on
> insert
> 
> I don't want to make up some delimeter because that wouldn't go so well....
> On a scale of 1 to 10 how bad of an idea is this?


Re: Storing a doc I'd as json array string

Posted by Stanley Iriele <si...@gmail.com>.
Thanks... I know doc ids have to be strings so when I "array string" I
meant json encoded string... It seems to work just fine so far but it
doesnt look too pleasant but I can't risk the idea of delimiter
collision...at all... I guess I could store the hash of those values or
something
On Mar 5, 2014 7:53 AM, "Marcello Barnaba" <vj...@openssl.it> wrote:

>
> On Mar 05, 2014, at 07:27, Stanley Iriele <si...@gmail.com> wrote:
>
> > I want to store a document for a particular game... Version...and
> > key...where key could be any string. I want there to be a key collision
> on
> > insert
> >
> > I don't want to make up some delimeter because that wouldn't go so well....
>
> If only the "key" field is out of your control and you can't assure the
> delimiter will not appear in it, you can put this field last. Then, when
> parsing the id, you split it up to the second delimiter.
>
> --
> ~ vjt@openssl.it
> ~ http://sindro.me
>
>

Re: Storing a doc I'd as json array string

Posted by Marcello Barnaba <vj...@openssl.it>.
On Mar 05, 2014, at 07:27, Stanley Iriele <si...@gmail.com> wrote:

> I want to store a document for a particular game... Version...and
> key...where key could be any string. I want there to be a key collision on
> insert
> 
> I don't want to make up some delimeter because that wouldn't go so well….

If only the “key” field is out of your control and you can’t assure the
delimiter will not appear in it, you can put this field last. Then, when
parsing the id, you split it up to the second delimiter.

-- 
~ vjt@openssl.it
~ http://sindro.me