managarten/packages/cards-database/src/seed.ts
Till JS 3fa218cbe0 chore(memoro): remove old NestJS backends (Phase 8+9)
Delete apps/memoro/apps/backend/ (NestJS) and apps/memoro/apps/audio-backend/
(NestJS) — all functionality has been ported to the new Hono/Bun servers
(apps/server/ and apps/audio-server/).

Also clean up root and memoro package.json scripts to remove references
to the old @memoro/backend and @memoro/audio-backend packages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 11:21:03 +02:00

105 lines
2.4 KiB
TypeScript

import { getDb, closeDb } from './client.js';
import { deckTemplates } from './schema/index.js';
/**
* Seed the database with initial data
*/
async function seed() {
console.log('Seeding database...');
const db = getDb();
try {
// Seed deck templates
const templates = [
{
title: 'Language Basics',
description: 'Learn basic vocabulary and phrases for a new language',
category: 'languages',
templateData: {
cards: [
{
cardType: 'flashcard' as const,
content: { front: 'Hello', back: 'Hallo', hint: 'Greeting' },
},
{
cardType: 'flashcard' as const,
content: { front: 'Goodbye', back: 'Auf Wiedersehen' },
},
],
settings: { language: 'de' },
tags: ['language', 'basics', 'german'],
},
isActive: true,
isPublic: true,
popularity: 100,
},
{
title: 'Math Fundamentals',
description: 'Essential math concepts and formulas',
category: 'education',
templateData: {
cards: [
{
cardType: 'quiz' as const,
content: {
question: 'What is 2 + 2?',
options: ['3', '4', '5', '6'],
correctAnswer: 1,
explanation: '2 + 2 equals 4',
},
},
],
settings: { difficulty: 'beginner' },
tags: ['math', 'basics'],
},
isActive: true,
isPublic: true,
popularity: 80,
},
{
title: 'Programming Concepts',
description: 'Core programming concepts and terminology',
category: 'technology',
templateData: {
cards: [
{
cardType: 'flashcard' as const,
content: {
front: 'Variable',
back: 'A named storage location in memory that holds a value',
},
},
{
cardType: 'flashcard' as const,
content: {
front: 'Function',
back: 'A reusable block of code that performs a specific task',
},
},
],
settings: {},
tags: ['programming', 'coding', 'basics'],
},
isActive: true,
isPublic: true,
popularity: 90,
},
];
console.log('Inserting deck templates...');
await db.insert(deckTemplates).values(templates).onConflictDoNothing();
console.log('Seeding completed successfully!');
} catch (error) {
console.error('Seeding failed:', error);
throw error;
} finally {
await closeDb();
}
}
seed().catch((error) => {
console.error('Seed script failed:', error);
process.exit(1);
});