I am currently working on a project in which we use couchbase 4.1 today for an e-commerce site.
I want to store our structures for the entire category of sites in Couchbase as a single document, and then request a specific category and return this category in some cases, and in other cases I would like to return the category and its child categories.
I'm sure I need to use an array indexer indexer to make this work efficiently, but I'm completely new to Couchbase, so I'm not sure how it should be structured (or even if possible).
Part of my document looks like this (there are 4 levels in the structure and about 8-10 categories of the top level):
{ "Categories": [ { "DisplayName": "Category One", "Id": 1, "Categories": [ { "DisplayName": "Child category", "Id": 10, "Categories": [ { "DisplayName": "Child child category", "Id": 100, "Categories": [ { "DisplayName": "Child child child category", "Id": 1000 }, { "DisplayName": "Sibling child category", "Id": 1001 } ] }, { "DisplayName": "Child", "Id": 101, "Categories": [ { "DisplayName": "Another child category", "Id": 2001 } ] } ] } ] } ] }
If I ask for Id = 100, I would like my result to look like this:
{ "DisplayName": "Child child category", "Id": 100, "Categories": [ { "DisplayName": "Child child child category", "Id": 1000 }, { "DisplayName": "Sibling child category", "Id": 1001 } ] }
In some cases, I'm not interested in children. I tried to create my query using an array (N1QL) to select into my arrays, but I'm not sure if this is possible even if there are levels of complex objects.
Can you give me some recommendations on how this is possible (even if this is so?). We use the Couchbase.NET client.
Regards Martin