const { v4: uuidv4 } = require('uuid'); class User { constructor(data) { this.id = data.id || uuidv4(); this.name = data.name; this.email = data.email; this.age = data.age; this.createdAt = data.createdAt || new Date().toISOString(); this.updatedAt = data.updatedAt || new Date().toISOString(); } toJSON() { return { id: this.id, name: this.name, email: this.email, age: this.age, createdAt: this.createdAt, updatedAt: this.updatedAt }; } update(data) { if (data.name !== undefined) this.name = data.name; if (data.email !== undefined) this.email = data.email; if (data.age !== undefined) this.age = data.age; this.updatedAt = new Date().toISOString(); return this; } } module.exports = User;