From 007f9deee0ab8937e8f8d9bf48e698c44a938fde Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Tue, 18 Jun 2024 15:42:12 +0200 Subject: [PATCH] feat(db): :sparkles: add listRef utility to get ref list from filter --- src/db/mod.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/db/mod.ts b/src/db/mod.ts index ec64ebf..8f201a3 100644 --- a/src/db/mod.ts +++ b/src/db/mod.ts @@ -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 = () => true, ) => this.#list(type, Builder, filter), + listRef: async ( + filter: (ressource: T) => boolean | Promise = () => true, + ) => { + const ressources: Ref[] = [] + for await (const ressource of this.#list(type, Builder, filter)) { + ressources.push(ressource.toRef() as Ref) + } + return ressources + }, } }