2024-08-10 17:10:57 +00:00
|
|
|
import { inject, injectable } from "tsyringe";
|
2024-08-13 22:19:57 +00:00
|
|
|
import { generateRandomAnimalName } from "$lib/utils/randomDataUtil";
|
|
|
|
|
import { CollectionsRepository } from "../repositories/collections.repository";
|
2024-08-10 17:10:57 +00:00
|
|
|
|
|
|
|
|
@injectable()
|
|
|
|
|
export class CollectionsService {
|
|
|
|
|
constructor(
|
|
|
|
|
@inject(CollectionsRepository) private readonly collectionsRepository: CollectionsRepository
|
|
|
|
|
) { }
|
|
|
|
|
|
2024-08-13 22:19:57 +00:00
|
|
|
async createEmptyNoName(userId: string) {
|
|
|
|
|
return this.createEmpty(userId, null);
|
|
|
|
|
}
|
2024-08-10 17:10:57 +00:00
|
|
|
|
2024-08-13 22:19:57 +00:00
|
|
|
async createEmpty(userId: string, name: string | null) {
|
|
|
|
|
return this.collectionsRepository.create({
|
|
|
|
|
user_id: userId,
|
|
|
|
|
name: name ?? generateRandomAnimalName(),
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-08-10 17:10:57 +00:00
|
|
|
}
|