Search code examples
javajsoncouchbasespring-data-couchbasecouchbase-java-api

Couchbase nested objects Type


I'm trying to find out the best way to get the type of a nested object in a couchbase document.

I have this document :

{
  "storeType": {
    "name": "Store"
  },
  "name": "Store",
  "_class": "common.domain.Store",
  "categories": [
    {
      "name": "Series",
      "displayable": false,
      "active": false,
      "highlights": [
        {
          "name": "Spiderman",
          "active": true
        },
        {
          "name": "Spiderman2",
          "active": true
        }
      ],
      "categoryId": "SERIES"
    }
  ],
  "storeId": "STORE::10",
  "order": 1
}

Spring data uses _class to find out the hole document type.

My question is :

How can I find the precise type of each object in categories list?

Thx a lot


Solution

  • Found the query to make the update. We used the collection operator WITHIN : UPDATE bucket b USE KEYS "Store::1" SET h.active = false FOR h WITHIN b.categories when h.cbHighlightId = "Highlight::1" END . Highlight is not a Document