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
+46
View File
@@ -0,0 +1,46 @@
[
{
"region": "Kanto",
"games": ["Red", "Blue", "Yellow", "LG: Pikachu", "LG: Eevee"]
},
{
"region": "Johto",
"games": ["Gold", "Silver", "Crystal", "HG", "SS"]
},
{
"region": "Hoenn",
"games": ["Ruby", "Sapphire", "Emerald", "OR", "AS"]
},
{
"region": "Sinnoh",
"games": ["Diamond", "Pearl", "Platinum", "BD", "SP"]
},
{
"region": "Unova",
"games": ["Black", "White", "Black2", "White2", "Dream Radar"]
},
{
"region": "Kalos",
"games": ["X", "Y"]
},
{
"region": "Alola",
"games": ["Sun", "Moon", "Moon Demo", "US", "UM"]
},
{
"region": "Galar",
"games": ["Sword", "Shield"]
},
{
"region": "Hisui",
"games": ["PLA"]
},
{
"region": "Paldea",
"games": ["Scarlet", "Violet"]
},
{
"region": "Unknown",
"games": ["Home", "Go"]
}
]
+13
View File
@@ -0,0 +1,13 @@
import mongoose, { Schema, Document } from 'mongoose';
export interface RegionGameMapping extends Document {
region: string;
games: string[];
}
const regionGameMappingSchema = new Schema<RegionGameMapping>({
region: String,
games: Array<string>
});
export default mongoose.model<RegionGameMapping>('RegionGameMapping', regionGameMappingSchema);
@@ -0,0 +1,25 @@
import RegionGameMappingModel, { type RegionGameMapping } from '$lib/models/RegionGameMapping';
class RegionGameMappingRepository {
async findById(id: string): Promise<RegionGameMapping | null> {
return RegionGameMappingModel.findById(id).exec();
}
async findAll(): Promise<RegionGameMapping[]> {
return RegionGameMappingModel.find().exec();
}
async create(data: Partial<RegionGameMapping>): Promise<RegionGameMapping> {
return RegionGameMappingModel.create(data);
}
async update(id: string, data: Partial<RegionGameMapping>): Promise<RegionGameMapping | null> {
return RegionGameMappingModel.findByIdAndUpdate(id, data, { new: true }).exec();
}
async delete(id: string): Promise<void> {
await RegionGameMappingModel.findByIdAndDelete(id).exec();
}
}
export default RegionGameMappingRepository;