skailan-conversations
Version:
Servicio de conversaciones y mensajería para Skailan
18 lines • 611 B
JavaScript
export class UpdateTag {
tagRepository;
constructor(tagRepository) {
this.tagRepository = tagRepository;
}
async execute(request) {
const { id, organizationId, ...updates } = request;
const existingTag = await this.tagRepository.findById(id, organizationId);
if (!existingTag) {
throw new Error('Tag not found.');
}
if (updates.name !== undefined)
existingTag.name = updates.name;
existingTag.updatedAt = new Date();
return this.tagRepository.save(existingTag);
}
}
//# sourceMappingURL=UpdateTag.js.map