Couchbase N1QL Query Update

Hi Team,
We have below nested json doc with __t = “irdb-np”
There are 1000’s of such documents that are loaded in couchbase data bucket

*{ *

  • “__t”: “irdb-np”,*
  • “cc”: “1”,*
  • “cnsranges”: {*
  • “12424”: {*
  •  "datetime": "20230530161118",*
    
  •  "dest": "Bahamas",*
    
  •  "iso2": "BS",*
    
  •  "loc": "0",*
    
  •  "maxsnlen": 7,*
    
  •  "minsnlen": 7,*
    
  •  "ndclen": 3,*
    
  •  "nsn": "2424",*
    
  •  "reg": "null",*
    
  •  "typeid": "MOB",*
    
  •  "userid": "IRDBUSER"*
    
  • },*
  • “12425”: {*
  •  "datetime": "20220924000000",*
    
  •  "dest": "Bahamas",*
    
  •  "iso2": "BS",*
    
  •  "loc": "0",*
    
  •  "maxsnlen": 7,*
    
  •  "minsnlen": 7,*
    
  •  "ndclen": 3,*
    
  •  "nsn": "2425",*
    
  •  "reg": "null",*
    
  •  "typeid": "MOB",*
    
  •  "userid": "IRDBUSER"*
    
  • }*
    }

The use case over here is to update the datetime attribute for all such documents.
Thanks,
Debasis

UPDATE mybucket AS b
SET b.cnsranges = OBJECT  n: OBJECT_PUT(v, "datetime", NOW_MILLIS()) FOR  n:v IN b.cnsranges END
WHERE b.__t = "irdb-np";
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.