[WIP] book tracker on the atmosphere~
at main 1.3 kB view raw
1import { sqliteTable, text } from 'drizzle-orm/sqlite-core'; 2import type { Record as BookRecord } from '$lexicon/book'; 3import { sql } from 'drizzle-orm'; 4import type { Author } from '$lexicon/defs'; 5 6export const authSession = sqliteTable('session', { 7 key: text('key').primaryKey(), 8 session: text('session', { mode: 'json' }).notNull() 9}); 10 11export const authState = sqliteTable('state', { 12 key: text('key').primaryKey(), 13 state: text('state', { mode: 'json' }).notNull() 14}); 15 16export const book = sqliteTable('book', { 17 uri: text('uri').primaryKey(), 18 authorDid: text('authorDid').notNull(), 19 createdAt: text('createdAt').notNull(), 20 indexedAt: text('indexedAt').notNull(), 21 22 OLID: text('OLID').notNull(), 23 title: text('title').notNull(), 24 authors: text('authors', { mode: 'json' }) 25 .notNull() 26 .$type<Author[]>() 27 .default(sql`'[]'`), 28 description: text('description').notNull(), 29 firstPublishedAt: text('firstPublishedAt').notNull() 30}); 31 32export type Session = typeof authSession.$inferSelect; 33export type State = typeof authState.$inferSelect; 34export type Book = typeof book.$inferSelect; 35 36type LexiconShape<T> = { 37 [K in keyof T as string extends K ? never : K extends '$type' ? never : K]: T[K]; 38}; 39const _typeCheckBook: LexiconShape<BookRecord> = {} as Book;