0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-24 22:46:02 -05:00

wip: move data seeding

This commit is contained in:
bholmesdev 2024-02-26 18:57:06 -05:00
parent 448edc14d5
commit cc23ba21de
3 changed files with 13 additions and 14 deletions

View file

@ -14,14 +14,5 @@ export default defineConfig({
db: {
tables: { Author },
unsafeDisableStudio: true,
async data({ seed }) {
await seed(Author, [
{ name: 'Ben' },
{ name: 'Nate' },
{ name: 'Erika' },
{ name: 'Bjorn' },
{ name: 'Sarah' },
]);
},
},
});

View file

@ -0,0 +1,13 @@
import { db, Author, Themes } from 'astro:db';
await db.insert(Themes).values([{ name: 'dracula' }, { name: 'monokai', added: new Date() }]);
await db
.insert(Author)
.values([
{ name: 'Ben' },
{ name: 'Nate' },
{ name: 'Erika' },
{ name: 'Bjorn' },
{ name: 'Sarah' },
]);

View file

@ -23,11 +23,6 @@ export function themes(): AstroIntegration {
updateConfig({
db: {
tables: { Themes },
async data({ seed }) {
// Seed writable tables in dev mode, only
// but in this case we do it for both, due to tests
await seed(Themes, [{ name: 'dracula' }, { name: 'monokai', added: new Date() }]);
},
},
});
},