Let({
blocks: Select(["data", "blocks"], Get(Ref(Collection("Blocks"), "299664869783765505"))),
entitiesArray: Map(Var("blocks"), block => ToArray(block)),
entities: Reduce((acc,value) => Append(acc, value) ,[],Var("entitiesArray")),
find: Filter(Var("entities"), entity => Equals(Select([1, "refs"], entity), Ref(Collection("xyz"), "1")))
},
ToObject(Var("find"))
)
But I would suggest revising the blocks
structure. Try to keep it as an array
"blocks": [
{"text": "Text1", "refs": Ref(Collection("xyz"), 1) },
{"text": "Text2", "refs": Ref(Collection("xyz"), 2) }
]
So FQL would be
Let({
blocks: Select(["data", "blocks"], Get(Ref(Collection("Blocks"), "299664869783765505"))),
find: Filter(Var("blocks"), entity => Equals(Select(["refs"], entity), Ref(Collection("xyz"), "1")))
},
Var("find")
)
Or an object
"blocks": {
"block_1": {
"text": "Text1",
"refs": Ref(Collection("xyz"), 1)
},
"block_2": {
"text": "Text2",
"refs": Ref(Collection("xyz"), 2)
}
}
FQL
Let({
blocks: Select(["data", "blocks"], Get(Ref(Collection("Blocks"), "299664869783765505"))),
entities: ToArray(Var("blocks")),
find: Filter(Var("entities"), entity => Equals(Select([1,"refs"], entity), Ref(Collection("xyz"), "1")))
},
ToObject(Var("find"))
)