Hi there,
I’d like to perform a query that retrieves any document that has a ref that is contained in an array of refs that I provide. And I’d like to do this without performing a scan of the collection.
I read this example on using an array of GETs. And is says:
This saves network bandwidth and processing by grouping several requests for data into the same operation.
Let’s say I am providing this array of refs:
const users = [
Ref(Collection("User"), "344499104832815692"),
Ref(Collection("User"), "344500844512674379")
]
And the query I’d like to run is:
const response = await this.client.query([
Ref(Collection("User"), "344499104832815692"),
Ref(Collection("User"), "344500844512674379"),
]););
But since there is no knowing what the users are at any given moment, I’d like this to be dynamic, depending on what’s in the users array.
Is there any way to programmatically use the users array to create a query like the above?
I’ve trie this and other variations, but to no avail.
const gets = users.map((user) => Get(user));
const response = await this.client.query(gets);
It seems like, if this is possible, that it would be a lot more efficient that performing a search.
Any helpful advice would be very appreciated.