import{eq as p}from"drizzle-orm";import{FIELDS_TO_SELECT_FOR_FILE_HASH as n}from"./utils.js";import{fileHashesTable as l}from"../../../providers/database/databases/main-sqlite/schemas/file-hashes-table.js";import{createFileHashReadModel as a}from"../mappers/create-file-hash-read-model.js";import{applyPagination as f}from"../../../providers/database/pagination/index.js";class _{#t;constructor(t){this.#t=t}async getFileHashes(t={}){const s=this.#t.client.select(n).from(l),e=this.#t.client.$count(s),c=s.$dynamic(),i=t.limit||10,m=f(c,{...t,limit:i+1}),[r,h]=await Promise.all([m.run(),e]),u=r.rows.length>i;return{items:r.rows.slice(0,i).filter(o=>o!==null).map(o=>a(o)),hasMore:u,total:h}}async getFileHashByHash(t){const e=(await this.#t.client.select(n).from(l).where(p(l.hash,t)).run()).rows[0];return e?a(e):null}}export{_ as FileHashesLocalReadRepository};
