feat(db): ✨ add listRef utility to get ref list from filter
This commit is contained in:
parent
28a517323b
commit
007f9deee0
|
@ -2,6 +2,7 @@ import {
|
|||
Credential,
|
||||
Group,
|
||||
Machine,
|
||||
type Ref,
|
||||
type Ressource,
|
||||
Service,
|
||||
User,
|
||||
|
@ -58,6 +59,15 @@ export class Db {
|
|||
list: (
|
||||
filter: (ressource: T) => boolean | Promise<boolean> = () => true,
|
||||
) => this.#list<T>(type, Builder, filter),
|
||||
listRef: async (
|
||||
filter: (ressource: T) => boolean | Promise<boolean> = () => true,
|
||||
) => {
|
||||
const ressources: Ref<T>[] = []
|
||||
for await (const ressource of this.#list<T>(type, Builder, filter)) {
|
||||
ressources.push(ressource.toRef() as Ref<T>)
|
||||
}
|
||||
return ressources
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue