Prefixing an Document ID Generated by Couchbase

44 views
Skip to first unread message

Steve

unread,
Oct 12, 2014, 5:25:27 AM10/12/14
to mobile-c...@googlegroups.com
Is it possible to prefix a document ID created by Couchbase? I know I can't modify the ID of a document, but I would like Couchbase to generate a unique ID for me and then prefix it with some constant.

CBLDocument* document = [database createDocument];

e.g. document.documentID = 78A799AA-5213-4199-AE4B-E7110B859674

// Then prefix it somehow...

e.g. document.documentID = user::78A799AA-5213-4199-AE4B-E7110B859674

Jens Alfke

unread,
Oct 13, 2014, 12:01:24 AM10/13/14
to mobile-c...@googlegroups.com

On Oct 12, 2014, at 2:25 AM, Steve <s.ande...@gmail.com> wrote:

Is it possible to prefix a document ID created by Couchbase? I know I can't modify the ID of a document, but I would like Couchbase to generate a unique ID for me and then prefix it with some constant.

Just create the document ID yourself by using NSUUID and appending that to a string. Then create the document by calling -[CBLDatabase documentWithID:].

—Jens

Steve

unread,
Oct 15, 2014, 10:27:16 AM10/15/14
to mobile-c...@googlegroups.com
Too easy, thanks Jens.
Reply all
Reply to author
Forward
0 new messages