Custom DocumentID & adding complex JSON

11 views
Skip to first unread message

parvez....@decurtis.com

unread,
May 21, 2017, 1:26:26 AM5/21/17
to Couchbase Mobile
I do have two questions:
Question 1. Is it possible to append a string to a DocumentID while creating a new document? For example can we have a documentID as ERROR:<DocumentID>? From the CBLDocument's class it seems to me that DocumentID is readOnly so I am looking for a way if we can have custom DocumentID or not.
Question 2. Can we store a complex JSON in a single field of a document?

Thanks

Jens Alfke

unread,
May 21, 2017, 1:27:17 PM5/21/17
to mobile-c...@googlegroups.com

> On May 20, 2017, at 10:26 PM, "parvez....@decurtis.com" <parvez....@decurtis.com> wrote:
>
> I do have two questions:
> Question 1. Is it possible to append a string to a DocumentID while creating a new document? For example can we have a documentID as ERROR:<DocumentID>? From the CBLDocument's class it seems to me that DocumentID is readOnly so I am looking for a way if we can have custom DocumentID or not.

You can have any docID you want. Just call [db documentWithID: @"whatever..."]. If the doc doesn't already exist, it will be created when you save it.

> Question 2. Can we store a complex JSON in a single field of a document?

Of course. Just set the property's value to an NSDictionary or NSArray, containing other JSON-compatible objects.

--Jens
Reply all
Reply to author
Forward
0 new messages