Reputation: 1
I am working with the demo of fauna. I Want to have the customer in the object, but now it is @refI work with NextJS. This is my object now. How can I get my customer info straight into my object?
Upvotes: -1
Views: 68
Reputation: 4521
Your question title asks one question, and the body asks another. Try to ask one question at a time. Also, try to use code blocks when asking about code: screenshots are not searchable, and provide an accessibility hurdle for folks with vision impairments.
For the title:
No. You can fetch up to 100 thousand documents in one query. When there are more than 100 thousand documents to retrieve, multiple queries are required.
Typically, one query would fetch documents from a single collection. If you have multiple collections, you would paginate through each collection, using as many queries as required to fetch all of the documents.
Plus, data may be attached to system schema documents, including indexes, functions, keys, tokens, credentials, access providers, collections, and databases. To capture all of these in one query, you could try starting with:
Map(
Paginate(
Union(
AccessProviders(),
Collections(),
Credentials(),
Databases(),
Functions(),
Indexes(),
Keys(),
Tokens()
)
),
Lambda("ref", Get(Var("ref")))
)
Each of the functions within the Union
call return a set of their respective documents. Union
combines them all into one set, and then Paginate
is used to return a single page of the overall result set. Just as in your query, Map
is used to iterate of the page of results, and the Lambda
is used to call Get
on each result entry in turn.
For the body:
Your query uses Map
to run Get
on each document matching the all_orders
index. The result is, necessarily, an array. As such, your customer info is in your object, but since it appears that you have three orders, all three are in the array.
Once the result is captured in the dbs
variable, you can (in your client code) run forEach
or map
on the array in dbs.data
. As you can see from the output, each document contains its own data
field. So, to access the first order's user-defined fields, they would be in dbs.data[0].data
.
Upvotes: 1