feat(db): ✨ allow async filter for ressource listing
This commit is contained in:
parent
fa88ab2f68
commit
8214dcd625
|
@ -105,7 +105,7 @@ export class Db {
|
|||
async *#list<T extends Ressource>(
|
||||
type: RessourceType<T>,
|
||||
Builder: RessourceBuilder<T>,
|
||||
filter: (entry: T) => boolean,
|
||||
filter: (entry: T) => boolean | Promise<boolean>,
|
||||
): AsyncGenerator<T, void, void> {
|
||||
const list = this.#kv.list<RessourceJson<T>>({
|
||||
prefix: [this.prefix.ressource, type],
|
||||
|
@ -114,7 +114,7 @@ export class Db {
|
|||
const value = entry.value
|
||||
//@ts-expect-error Type union of Ressource types for Builder
|
||||
const ressource = Builder.fromJSON(value) as T
|
||||
if (filter(ressource)) {
|
||||
if (await filter(ressource)) {
|
||||
yield ressource
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue