How to implement a technique to only store users having different phone numbers?
Application Type
Reactive

Suppose I've designed a form that collects user information and phone number field in the form. I want to store unique users. If anyone gives an already existing phone number, a warning should appear.

mvp_badge
MVP
Solution

Hi Kush,


Before registering / updating the user, you make a query to find a different user with the same phone number.



You just need to check if the output is not empty: if it is not, then there is a different user with the same phone number; otherwise there is no user with that phone number. Something like the flow below:


Kind Regards,
João


Hey Marques

Thank you so much. It's working.


Regards

Kush

Hi,

As Joao mentioned you can have a check in your registration action by add an aggregate using User entity to fetch if any user exists with same mobile no. If exists give an warning.

Regards,

Biswajit

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.