ConusAI vendor v0.1.0-dev.20261013+85463d22
This commit is contained in:
parent
c3c6526952
commit
0da8a2a81b
@@ -23,6 +23,16 @@ export function fileRepository(db: Db) {
|
||||
return db.select().from(files).where(eq(files.noteId, noteId))
|
||||
},
|
||||
|
||||
/** The attachment, or `undefined` when `authorId` did not attach it. */
|
||||
async get(id: string, authorId: string): Promise<FileRow | undefined> {
|
||||
const [row] = await db
|
||||
.select()
|
||||
.from(files)
|
||||
.where(and(eq(files.id, id), eq(files.authorId, authorId)))
|
||||
.limit(1)
|
||||
return row
|
||||
},
|
||||
|
||||
/** Every attachment the visitor made, across their notes. */
|
||||
async listByAuthor(authorId: string): Promise<FileRow[]> {
|
||||
return db.select().from(files).where(eq(files.authorId, authorId))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export { files, type FileRow } from './model/schema'
|
||||
export { fileId } from './model/id'
|
||||
export { MAX_UPLOAD_BYTES, ALLOWED_CONTENT_TYPES, uploadLimits, type UploadCandidate } from './model/limits'
|
||||
export { fileRepository, type NewFile } from './api/repository'
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
/** A file id as it arrives in a URL or a form: a UUID, nothing else. */
|
||||
export const fileId = z.uuid()
|
||||
Reference in New Issue
Block a user