ok, let me make this even harder:)
so, I have a document of this structure
DOCUMENT 1
“d”: {
“chart_data”: {
“293778748”: 174,
“311395856”: 446,
“329218549”: 74,
“359917414”: 238,
“372836496”: 418,
“387301602”: 457,
“403858572”: 330,
“406889139”: 61,
“420009108”: 176,
“431946152”: 8,
“457446957”: 349,
“466965151”: 322
}
}
and another document with the key app:key_id_of_chart_data_array
with a document of the format:
DOCUMENT 2
{
“uuid”: “070899ba-5e93-4905-bc1d-375d636f7eff”,
}
DOCUMENT 3
{
value: 3
}
now I need to update the*value" from DOCUMENT3 (document key meta:docuemnt2uuid value) with the value of the document1->chart_data->array_value if the value is bigger than the one from document3 value
Is this something possible to be done?
LATER EDIT:
using this query:
SELECT OBJECT TO_STR(v3.document_key):TO_STR(d.chart.[TO_STR(v3.app_id)]) FOR v3 IN app_details END
FROM tracker AS d USE KEYS "document_id"
LET app_key = (
SELECT RAW "meta:" || d2.app_uuid || ":" || d.cc AS metakey
FROM `app-live` AS d2 USE KEYS ARRAY "app:a2t:" || v FOR v IN OBJECT_NAMES(d.chart_apps) END),
app_details = (
SELECT app_storage.app_app AS app_id,
`key` AS document_key
FROM `app-live` AS d3 USE KEYS ARRAY v2 FOR v2 IN app_key END);
I am getting this document:
[
{
“$1”: {
“meta:00105f4b-fb76-4db7-8b19-643ec749191b:us”: “260”,
“meta:001c4696-75cd-40c8-a9d1-f604f612dd23:us”: “286”,
“meta:01275a85-53f5-4fd2-9666-064dfd60abc4:us”: “301”,
}
}
]
now, should I do something like :
UPDATE default d USE KEYS OBJECT_NAMES($obj)
SET d.`value` = $obj.[META(d).id]
WHERE d.`value` < $obj.[META(d).id];
is the object structure (I just generated ) correct for the update query you mentioned?