Hi I want to know if I can add items into a subdocument which does not exist in the subdocument yet.
I tried below code but it simply fails when an existing item is encountered. I just want to neglect these items.
Getting the subdocument and checking unique items is not a good option for me since the subdocument is really big.
I have solved this problem with N1QL instead of subdocument API. Bevause subdoument API prevents all operations if ever, a STATUS_PATH_EXISTS error arises.
I am leaving my DSL in case someone else searches for a solution:
final Statement statement = update("bucketname")
.set("devices", arrayPut("devices", "value1", "value2"));
This simply add value1 and value2 to devices attribute of the document with id “id” in. It automatically neglects already existing values. If value1 already exists in devices array, it will be skipped.