25 lines
546 B
TypeScript
25 lines
546 B
TypeScript
import {
|
|
createPentagon,
|
|
TableDefinition,
|
|
} from 'https://deno.land/x/pentagon@v0.1.5/mod.ts'
|
|
import { TodoModel, UserModel } from '@homeman/models.ts'
|
|
|
|
export const kv = await Deno.openKv('homeman.db')
|
|
|
|
export const schema: Record<string, TableDefinition> = {
|
|
users: {
|
|
schema: UserModel,
|
|
relations: {
|
|
assignedTodos: ['todos', [TodoModel], 'id', 'assigneeUserId'],
|
|
},
|
|
},
|
|
todos: {
|
|
schema: TodoModel,
|
|
relations: {
|
|
assignee: ['users', UserModel, 'assigneeUserId', 'id'],
|
|
},
|
|
},
|
|
}
|
|
|
|
export const db = createPentagon(kv, schema)
|