export class UpdatePostCommandHandler {
  constructor(postRepository) {
    this.postRepository = postRepository;
  }

  async handle(command) {
    const postData = {};
    if (command.title) postData.title = command.title;
    if (command.content) postData.content = command.content;
    if (command.author) postData.author = command.author;
    
    const result = await this.postRepository.update(command.id, postData);
    if (!result) {
      throw new Error('Post not found');
    }
    return result;
  }
}
