import 'reflect-metadata' // docs say this has to be imported first in the entrypoint
import { type SQLQueryBindings } from "bun:sqlite"

import { openDB, DB } from "./db"
import { field, validate, schema } from './schema'

export { openDB, DB }
export { field, validate, schema }

export interface HasID {
    id: string | number
}
export type QueryOpts = {
    limit?: number
    offset?: number
    order?: string
}

// types that can be used in sql
export type Atom = string | number | boolean | null

// query("SELECT * FROM users WHERE id = $id", { id: 1 })
export type SQLArgs = SQLQueryBindings

// What all() and one() accept
export type Where<T> = Partial<T> | QueryOpts | (Partial<T> & QueryOpts)