Function: makeScanResult()
makeScanResult<
Options>(options,getScanIterator):ScanResult<KeyTypeForScanOptions<Options>,ReadonlyJSONValue>
A helper function that makes it easier to implement ReadTransaction.scan with a custom backend.
If you are implementing a custom backend and have an in memory pending async iterable we provide two helper functions to make it easier to merge these together. mergeAsyncIterables and filterAsyncIterable.
For example:
const scanResult = makeScanResult(
  options,
  options.indexName
    ? () => {
        throw Error('not implemented');
      }
    : fromKey => {
        const persisted: AsyncIterable<Entry<ReadonlyJSONValue>> = ...;
        const pending: AsyncIterable<Entry<ReadonlyJSONValue | undefined>> = ...;
        const iter = await mergeAsyncIterables(persisted, pending);
        const filteredIter = await filterAsyncIterable(
          iter,
          entry => entry[1] !== undefined,
        );
        return filteredIter;
      },
);
Type Parameters
Options
Options extends ScanOptions
Parameters
options
Options
getScanIterator
Options extends ScanIndexOptions ? GetIndexScanIterator : GetScanIterator
Returns
ScanResult<KeyTypeForScanOptions<Options>, ReadonlyJSONValue>