mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-07-13 02:53:45 +00:00
feat(#5): Add ability to seed pokedex entry data
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import PokedexEntryModel, { type PokedexEntry } from '$lib/models/PokedexEntry';
|
||||
|
||||
class PokedexEntryRepository {
|
||||
async findById(id: string): Promise<PokedexEntry | null> {
|
||||
return PokedexEntryModel.findById(id).exec();
|
||||
}
|
||||
|
||||
async findAll(): Promise<PokedexEntry[]> {
|
||||
return PokedexEntryModel.find().exec();
|
||||
}
|
||||
|
||||
async create(data: Partial<PokedexEntry>): Promise<PokedexEntry> {
|
||||
return PokedexEntryModel.create(data);
|
||||
}
|
||||
|
||||
async update(id: string, data: Partial<PokedexEntry>): Promise<PokedexEntry | null> {
|
||||
return PokedexEntryModel.findByIdAndUpdate(id, data, { new: true }).exec();
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<void> {
|
||||
await PokedexEntryModel.findByIdAndDelete(id).exec();
|
||||
}
|
||||
}
|
||||
|
||||
export default PokedexEntryRepository;
|
||||
Reference in New Issue
Block a user