I have a server action which uploads a csv file and the file is then used to populate a user table. This all works as expected.
However, I am trying figure out how now to add some logic so that if the email already exist in the user table do not create a new User and skip to the next user in the list and so on…
How do I do this? Is it as simple as adding a validation of a all user query in the repeat
On the repeat first check the users email against all emails like below or some other method?
The validation step is not suitable here.
What you need is a database query inside the repeat, filter it by the email returned by the repeat.
Then add a condition after the query - if the query returns NO results i.e. the email does not exist
Then - insert step
Else - nothing