Intro
Hi everyone, Although I read the Couchbase documentation, it was unclear to me. I want to update specific field's values in Couchbase. I can't figure out how to do this because the structure is a little it complex.
The Structure
"shops": {
"1": {
"workingHours": [
{
"interval": {
"closed": 15,
"open": 9
},
"info": {
"name": xBurger,
"location": London
}
},
{
"interval": {
"closed": 18,
"open": 8
},
"info": {
"name": Pizzeria,
"location": Venice
}
},
]
NEEDS
I need to change the open-closed hours. If open-closed hour is 9-15 -> change it to 12-20 If open-closed hour is 8-18 -> change it to 10-16
This will do it
UPDATE `your-bucket`
SET wh.interval.open = 12 FOR wh IN `your-bucket`.`shops`.`1`.`workingHours` WHEN (wh.interval.open = 9 AND wh.interval.closed = 15) END,
wh.interval.closed = 20 FOR wh IN `your-bucket`.`shops`.`1`.`workingHours` WHEN (wh.interval.open = 9 AND wh.interval.closed = 15) END,
wh.interval.open = 10 FOR wh IN `your-bucket`.`shops`.`1`.`workingHours` WHEN (wh.interval.open = 8 AND wh.interval.closed = 18) END,
wh.interval.closed = 16 FOR wh IN `your-bucket`.`shops`.`1`.`workingHours` WHEN (wh.interval.open = 8 AND wh.interval.closed = 18) END
just make sure to replace your-bucket with your real bucket name