{
"ADD": {
"k_2": [
{
"allowed": false,
"vs": "k_a"
},
{
"allowed": false,
"vs": "k_d"
}
],
"k_9": [
{
"allowed": false,
"vs": "k_f"
},
{
"allowed": true,
"vs": "k_a"
}
]
},
"REMOVE": {
"k_4": [
{
"allowed": true,
"vs": "k_a"
}
],
"k_7": [
{
"allowed": false,
"vs": "k_g"
},
{
"allowed": true,
"vs": "k_a"
}
]
}
}
This is my sample document. I want to delete those objects from array whose “vs” value is something, let’s say “k_a”. So the final output will be -
{
"ADD": {
"k_2": [
{
"allowed": false,
"vs": "k_d"
}
],
"k_9": [
{
"allowed": false,
"vs": "k_f"
}
]
},
"REMOVE": {
"k_4": [],
"k_7": [
{
"allowed": false,
"vs": "k_g"
}
]
}
}
This is the query I tried, but it wasn’t working. Can anyone please tell what am I doing wrong?
UPDATE sourceprioritization sp
SET obj = ARRAY v FOR v IN obj WHEN v.vs != "k_a" END
FOR obj IN OBJECT_VALUES(sp.ADD) END WHERE META(sp).id = "SPT|O|789"
Note - Here the keywords “ADD” and “REMOVE” are static but anything of the form “k_number” or “k_letter” is dynamic, and can be anything.
Any help is highly appreciated.