Hi ,
How to update multiple subdocuments in an entity using N1QL.
Hi ,
How to update multiple subdocuments in an entity using N1QL.
what do you means update multiple subdocuments? can you give an example?
for update multiple property,you can update as following
UPDATE default
SET field1 = "NewValue1",
field2 = "NewValue2",
field3 = "NewValue3",
USE KEYS ["doc1key"]
RETURNING *
FYI
SET path = expression [update-for] [ , path = expression [update-for] ]*
thanks …
below is the structure and am trying to update whole document including subdocument
{"field1": 0,
"field2": "6/9/2017 7:54:22 PM",
"field3": [
{
"Name": "vc2",
"Id": "0284236"
},
{
"Name": "vc",
"Id": "0288456"
}
]
}
I used - update bucketname set feild1 = “” but sub documents are not getting updated.
sorry, I am still confused, do you want to update
{"field1": 0,
"field2": "6/9/2017 7:54:22 PM",
"field3": [
{
"Name": "vc2",
"Id": "0284236"
},
{
"Name": "vc",
"Id": "0288456"
}
]
}
to
{
"field1": ""
}
?
thanks again …
i want to update the whole document including the sub document like below , only field2 remains unchanged
atom_yang1m
sorry, I am still confused, do you want to update
{“field1”: “xyz”,
“field2”: “6/9/2017 7:54:22 PM”,
“field3”: [
{
“Name”: “vc3”,
“Id”: “113”
},
{
“Name”: “cat”,
“Id”: “345”
}
]
}
i want to update the whole document including the sub document like below , only field2 remains unchanged
{“field1”: “xyz”,
“field2”: “6/9/2017 7:54:22 PM”,
“field3”: [
{
“Name”: “vc3”,
“Id”: “113”
},
{
“Name”: “cat”,
“Id”: “345”
}
]
}
try this
UPDATE default
USE KEYS ["dockey"]
SET field1 = "xyz",
field3 = [
{
"Name": "vc3",
"Id": "113"
},
{
"Name": "cat",
"Id": "345"
}
]
RETURNING *
thank you for the help.