Help On NQL Query

Hi Team,

We had doc meta id (nws-43-388-<cos_value>-658) and docs as below.
nws-43-388-30001-658
{
“__t”: “nws”,
“nwid” : 43,
“code” : 388,
“cos” : 30001,
“wid” : 658,
“mcc” : “404”,
“mnc” : “75”,
}

We want to perform the NQL operation after that new document content will be as below and meta id also will be change to (nws-43-388-<cos_value>-658).
nws-43-388-30002-658
{
“__t”: “nws”,
“nwid” : 43,
“code” : 388,
“cos” : 30002,
“wid” : 658,
“mcc” : “404”,
“mnc” : “75”,
}

We had tried with select + insert but it is not working as expected.

Could provide any suggestion to achieve the same.

Thanks,
Debasis

As couchbase key is immutable

UPSERT INTO default (KEY CONCAT2("-",t.__t, TOSTR(t.nwid),TOSTR(t.code),TOSTR(t.cos).TOSTR(t.wid) ), VALUE t)
SELECT OBJECT_CONCAT(t, {"cos":30002}) AS t FROM default AS t USE KEYS "nws-43-388-30001-658"
WHERE .....

delete old document

1 Like