feat(*): Add region-game mappings

This commit is contained in:
Josh Creek
2024-07-14 19:45:06 +01:00
parent 80fb0d7414
commit 62c03f41eb
4 changed files with 92 additions and 0 deletions
+8
View File
@@ -2,8 +2,11 @@ import { json } from '@sveltejs/kit';
import { dbConnect, dbDisconnect } from '$lib/utils/db';
import PokedexEntryModel from '$lib/models/PokedexEntry';
import PokedexEntryRepository from '$lib/repositories/PokedexEntryRepository';
import RegionGameMapping from '$lib/models/RegionGameMapping';
import RegionGameMappingRepository from '$lib/repositories/RegionGameMappingRepository';
import PokedexMetadataModel from '$lib/models/PokedexMetadata';
import dex from '$lib/helpers/pokedex.json';
import RegionGameMappingJson from '$lib/helpers/region-game-mapping.json';
// Function to update the lastModified field in the metadata collection
const updateLastModified = async () => {
@@ -23,6 +26,7 @@ export const GET = async () => {
await dbConnect()
.then(async () => {
// Create pokedex entries
const repo = new PokedexEntryRepository();
dex.forEach(async (pokemon: PokedexEntryModel) => {
@@ -30,6 +34,10 @@ export const GET = async () => {
console.log(`Seeded ${pokemon.pokedexNumber} ${pokemon.pokemon} ${pokemon.form}`);
});
// Create region-game mappings
const regionGameMappingRepository = new RegionGameMappingRepository();
await regionGameMappingRepository.create(RegionGameMappingJson as RegionGameMapping[]);
// Update the lastModified field after seeding
await updateLastModified();
})