mirror of
https://github.com/withastro/astro.git
synced 2025-02-24 22:46:02 -05:00
26 lines
576 B
TypeScript
26 lines
576 B
TypeScript
import { column, defineDb, defineTable } from 'astro:db';
|
|
|
|
const Recipe = defineTable({
|
|
columns: {
|
|
id: column.number({ primaryKey: true }),
|
|
title: column.text(),
|
|
description: column.text(),
|
|
},
|
|
});
|
|
|
|
const Ingredient = defineTable({
|
|
columns: {
|
|
id: column.number({ primaryKey: true }),
|
|
name: column.text(),
|
|
quantity: column.number(),
|
|
recipeId: column.number(),
|
|
},
|
|
indexes: {
|
|
recipeIdx: { on: 'recipeId' },
|
|
},
|
|
foreignKeys: [{ columns: 'recipeId', references: () => [Recipe.columns.id] }],
|
|
});
|
|
|
|
export default defineDb({
|
|
tables: { Recipe, Ingredient },
|
|
});
|