After uploading csv list how to create db record only if the email does not exist

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?


Thanks!

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

1 Like

Thanks, makes sense, had a feeling it might be a condition.

Cheers

Hi @Teodor

Just following up on this method. This works but is this the correct way to do this?

You can directly check:

{{!check_user_email.email}}
2 Likes