I have document structure like below and want to pull documents whose keys are in snapShotId as in the given document. I am unable to unnest the value of snapShotsMappings with USE KEYS by writing the query something like below. Can anyone help me out in getting the query correct.
SELECT p.*
FROM promotions AS p
USE KEYS ARRAY_FLATTEN((SELECT snaps.snapShotId
FROM promotions UNNEST snapShotsMappings as snaps USE KEYS “3068b1e2-5cb6-458f-bfae-f1b9fe638b11”),1)
SELECT p.*
FROM promotions AS p
USE KEYS ARRAY_FLATTEN((SELECT RAW eventIds
FROM promotions USE KEYS "3068b1e2-5cb6-458f-bfae-f1b9fe638b11" WHERE ANY v IN snapShotsMappings SATISFIES v. snapShotId ="eff84cc6-4223-4e6f-840b-aeaa16408890" END ),1)
Apologies if I hadn’t explain the problem correctly.
There is no participation of eventIds in the query,
I have updated the document to get more clear representation by removing eventIds from document.
Suppose the above document documentId is 1234567890.
snapShotsMappings.snapShotId represents document Ids of other documents. I need to write a query to pull all the documents whose document Id is in snapShotsMappings.snapShotId.
Something like below:
SELECT p.*
FROM promotions AS p
USE KEYS ARRAY_FLATTEN((SELECT snaps.snapShotId
FROM promotions UNNEST snapShotsMappings as snaps USE KEYS “1234567890”),1)
USE KEYS must be allowed only after bucket. Check syntax.
SELECT p.*
FROM promotions AS p
USE KEYS ARRAY_FLATTEN((SELECT RAW snapShotsMappings[*].snapShotId
FROM promotions USE KEYS "1234567890"),1)
OR
SELECT p.*
FROM promotions AS p
USE KEYS ARRAY_FLATTEN((SELECT RAW snaps.snapShotId
FROM promotions USE KEYS "1234567890" UNNEST snapShotsMappings as snaps ),1)