Query Data
APIโ
queryStake
โ
async function queryStake(amount: bigint, options = { usd: false });
Stakes the specified amount of funds in order to perform queries.
amount
is abigint
typeoptions
is an object with a single optional property,usd
, which is a boolean indicating whether the amount is in USD.
query
โ
async function query(
streamDefinition: StreamDefinition,
input: QueryInput,
onMessage?: MessageListener,
): Promise<LogStoreMessageStream>;
Queries a stream for historical data.
streamDefinition
is an object containing the stream ID and partition that should be queried.input
is an object that defines the query options. It can be of typeQueryInput
and can have different forms likeQueryLast
,QueryRange
,QueryFrom
.onMessage
is an optional callback function for each message retrieved from the stream.
Returns a Promise that resolves to a LogStoreMessageStream
object, providing an alternative way of iterating through the messages.
Exampleโ
// Staking some funds for the purpose of making a query
await logStoreClient.queryStake(STAKE_AMOUNT);
const queryResult = await logStoreClient.query(myStreamId, {
from: {
timestamp: 1685272949531,
},
to: {
timestamp: 1685272962273,
},
});