How to delete double entries in the database?

Hello bubblers! :wave:t2:

I’m struggling with a problem… :confounded:

I will try to explain it below. :point_down:t2:

So in my app I want to give my users the ability to import a list of emails in the database and then be able to send an email to all those imported emails.

That part was easy peasy…

In my app I have a FileUploader and from it they can upload a file in .csv form

Then in the workflow I have:

When FileUploader value is changed —> Upload data as CSV

And that works perfectly. :white_check_mark:

Now the problem… :confounded:

If a user upload that same file but upgraded (for example before in that file there were 50 email and then they add 10 new email to that file) the problem that I have is that now in my database there are 110 emails :sweat_smile:

50 emails from the first time they uploaded the file

plus

60 emails from the second time they uploaded that same file

How can I delete automatically the 50 emails that are already in my database and only keep the 10 new emails :question:

Any advice will be much appreciated :pray:t2:

Check this out: https://youtu.be/Ulcl0qc0o5Y

Let me know if it is helpful, please.


@bestbubbledev - Youtube | Patreon | LinkedIn | Twitter

duplicates are eventual. you should utilize :unique elements which will filter out duplicates.

Hi mate, thanks for you reply!

Unfortunately that doesn’t help…

I watched that video many times.

He delete the duplicate one by one by creating a repeating group that shows only the duplicates.

That’s should be ok if you have to delete just a few… but what about 50+ ?

Also he used “Crate new thing” in his workflow, in that scenario he can use “Only when”, etc. to prevent duplicates.

But in my case by using “Upload data as CSV” action in my workflow the data from the .csv file my users upload, are automatically imported in my database.

That’s way I should need something I guess, that will let automatically delete the duplicate entries in my database…

You don’t want to consume any more usage from your app than you’d need to, more server side workflows would be extremely redundant. Just use :unique elements. You should allow duplicate entries, without checking if exists already skip, or whatever; redundant and wasteful. Then, when you’re searching for your list of users to email, it would just be something like Search for User’s email:unique elements

A few ideas.

  1. Upload to a temporary table, then run a backend workflow that iterates over that to add only ‘new’ emails
  2. Have a database trigger that checks for duplicates when a new email is added
1 Like

For starters I’d suggest to take above suggestions by @NigelG & @doug.burden into account.

This being said I’d use the method, in the link above, to identify duplicates and then run a Backend Workflow to delete them. Recursive workflow to delete them one by one until there’s none left.

1 Like

Hello could you solve this problem? If you could, can you please share the process. I am facing the same issue here.

Hi, i do not if @andrea.dambrosio.job or @christinajessy111 could resolve in a better way, but i had the same problem as you:

i am building a store, this store create carts for user, each product is a cart (so if you want a soda it creats a objet(cart) with name, price and quantity) the problem that i had was:

1.- a (Not logged) user add things to its basket
2.- this creates a cart related to this temporary user
3.- when the user logged in, chart changes its owner from temporary user to logged in user.

but what happen if the customer start a new session in another web page?
1.- again they create a basket and it is related to temporary user
2- when logged in, i have to migrate the carts from temporary user to the logged in user…
3.- but… if the logged in user already had a “coke soda” and i migrated the cart from the temporary user… there is going to be 2 “coke Sodas” and they are not going to add each other im going to have 2 same carts

what i did to elimitate duplicates? use this on the constraints.


i verify the search is only for thi current user and then use “Anyfields contains” as a constaint (what does this is look on each field of the objets)


and made a search of other carts specific field in my case each items´product of the previous user.