In Couchbase I have documents that contain a dictionary structured like this:
{
"...": "...",
"members": {
"*USERID*": {
"...": "..."
}
}
}
Now I want to use a N1QL Query to get all documents where my user id is in members
. I have tried many different queries, but I was not able to find a working N1QL query.
What does a N1QL Query look like that selects all documents with a specified user id as a key in the members
map?
SELECT d.*
FROM default AS d
WHERE d.`members`.["myuserid"] IS NOT NULL;
OR
SELECT d.*
FROM default AS d
WHERE ANY n IN OBJECT_NAMES(d.`members`) SATISFIES n = "myuserid" END;
OR
SELECT d.*
FROM default AS d
WHERE ANY n:v IN d.`members` SATISFIES n = "myuserid" END;