Interface: Collection<T>
Extends
AsyncIterable<T>
Extended by
Type Parameters
| Type Parameter |
|---|
T |
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
createdAt |
readonly |
Date |
In UTC. |
options? |
readonly |
CollectionOptions |
- |
updatedAt |
readonly |
Date |
In UTC. |
Methods
[asyncIterator]()
asyncIterator: AsyncIterator<T>;
Enables for-await-of iteration.
Returns
AsyncIterator<T>
Example
Iterate through a large append log
// Ensure you import DataPowers
import { DataPowers, CollectionType, CollectionExpirationMode } from "@andi/powers";
type FiSkillLog = {
data: string;
};
const skillLogs = await DataPowers.getOrCreateCollection<FiSkillLog>(CollectionType.Dictionary, "log", { expiry: { expireMode: CollectionExpirationMode.Never } });
// Sometimes the logs may grow beyond what's performant to load all at once in memory. Use an async iterator to process each log, line by line
for await (const log of skillLogs) {
// granular processing
}
Overrides
AsyncIterable.[asyncIterator]
getSize()
getSize(): Promise<number>;
Returns
Promise<number>