Sequence number - Unique ID

41 views
Skip to first unread message

Sandra

unread,
Apr 22, 2014, 1:33:45 PM4/22/14
to mobile-c...@googlegroups.com
Hello,
   I need to assign certain items a unique ID, I'm thinking of a sequence number but I don't know how to implement in couch base something equivalent to SQL auto number field.
   Any advice is welcome,
   Thank you, Sandra

Jens Alfke

unread,
Apr 22, 2014, 1:37:42 PM4/22/14
to mobile-c...@googlegroups.com

On Apr 22, 2014, at 10:33 AM, Sandra <txm...@gmail.com> wrote:

   I need to assign certain items a unique ID, I'm thinking of a sequence number but I don't know how to implement in couch base something equivalent to SQL auto number field.

Use a UUID. You can’t use a counter because of replication — there’s no way for all of the clients that replicate with the same server to coordinate on what value the counter should have.

If it’s the document ID that needs to be unique, just use the createDocument method. It assigns a UUID for the document ID.

—Jens

Sandra

unread,
Apr 25, 2014, 12:10:03 PM4/25/14
to mobile-c...@googlegroups.com
Thank you Jens.
Would you please re-direct me to some document where I can learn about UUID?

Traun Leyden

unread,
Apr 25, 2014, 12:59:29 PM4/25/14
to mobile-c...@googlegroups.com
Check out http://en.wikipedia.org/wiki/Universally_unique_identifier for background info.

You don't need to write any code yourself, because couchbase lite will auto-assign a UUID as long as you don't provide your own _id.


--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/1a54705a-ceaa-4770-a24f-2866885e71a2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages