Display custom content based on the results of a query
await
block, along with the runQuery
function lets you manually run queries in a synchronous manner. This is useful when you want to display custom content based on the results of a query.
await
block: pending
, fulfilled
and rejected
. You can use the {:then}
and {:catch}
blocks to handle the fulfilled
and rejected
states respectively.
runQuery
function is a built-in function that lets you run queries synchronously. It takes a query name as an argument and returns the result of the query.
In addition to the query name, this function can have these three attributes:
{:then}
block, will be the data returned by the query. This data is structured as an array of objects, where each object represents a row in the query result. For example: