Can I use nested (embedded) documents in Couchbase

I’ve thought that I read all of the Couchbase Documentations. I think I found a new one.

And I couldn’t find how can delete this question. I’m sorry for this. Thanks.


I need to use nested documents in Couchbase like the following. I’m using Couchbase Lite PhoneGap plugin. Can I query using Couchbase Lite APIs or N1QL?

(address field is embedded as a second document )

{
    username: "john",
    name: "John Crouch",
    address: { "city": "Fortworth", "state": "Texas", "country": "United States" },
    phone: "3594584"
}

ps: I’ve found a N1QL guide regarding nested document querying. But there are no any words regarding IOS, Android and also particularly Couchbase Lite PhoneGap plugin.

(Sounds like you figured it out, but I’ll answer the question here for the benefit of anyone else who finds it later.)

That’s not considered a nested document; it’s just a JSON object (or “map” or “dictionary”) embedded in the document.

Couchbase Lite does not support N1QL. Querying is done with map/reduce, as in the production versions of Couchbase Server. Your map function can easily access any data found in nested objects in a document.

Thank you for your respond Jens,

You’re right. I’d tried to bring message to Mobile but already it’s in Couchbase Lite. Thanks :sweat_smile:

I’m following you…