0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-24 22:46:02 -05:00
astro/packages/db/test/fixtures/ticketing-example/astro.config.ts
2024-02-26 18:27:22 -05:00

57 lines
1.3 KiB
TypeScript

import db, { defineTable, column } from '@astrojs/db';
import node from '@astrojs/node';
import react from '@astrojs/react';
import { defineConfig } from 'astro/config';
import simpleStackForm from 'simple-stack-form';
const Event = defineTable({
columns: {
id: column.number({
primaryKey: true,
}),
name: column.text(),
description: column.text(),
ticketPrice: column.number(),
date: column.date(),
location: column.text(),
},
});
const Ticket = defineTable({
columns: {
eventId: column.number({ references: () => Event.columns.id }),
email: column.text(),
quantity: column.number(),
newsletter: column.boolean({
default: false,
}),
},
});
// https://astro.build/config
export default defineConfig({
integrations: [simpleStackForm(), db(), react()],
output: 'server',
adapter: node({
mode: 'standalone',
}),
db: {
tables: {
Event,
Ticket,
},
data({ seed, mode }) {
if (mode === 'dev') {
seed(Event, [
{
name: 'Sampha LIVE in Brooklyn',
description:
'Sampha is on tour with his new, flawless album Lahai. Come see the live performance outdoors in Prospect Park. Yes, there will be a grand piano 🎹',
date: new Date('2024-01-01'),
ticketPrice: 10000,
location: 'Brooklyn, NY',
},
]);
}
},
},
});