Skip to content

Commit

Permalink
fix: return null when can't find user with findByCpf method
Browse files Browse the repository at this point in the history
  • Loading branch information
arakakimath committed Feb 25, 2025
1 parent 8e06eb4 commit e991804
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ export class MongooseDeliveryPeopleRepository
async findByCpf(cpf: string) {
const deliveryPerson = await this.mongoose.user.findOne({ cpf })

return DeliveryPerson.create(
{
name: deliveryPerson.name,
cpf: deliveryPerson.cpf,
admin: deliveryPerson.admin,
password: deliveryPerson.password,
},
new UniqueEntityID(deliveryPerson._id),
)
return deliveryPerson
? DeliveryPerson.create(
{
name: deliveryPerson.name,
cpf: deliveryPerson.cpf,
admin: deliveryPerson.admin,
password: deliveryPerson.password,
},
new UniqueEntityID(deliveryPerson._id),
)
: null
}
}

0 comments on commit e991804

Please sign in to comment.