mongo-seeding icon indicating copy to clipboard operation
mongo-seeding copied to clipboard

Prevent duplicates while seeding

Open dominicrico opened this issue 4 years ago • 3 comments

Like other ORM-based seeders, it would be awesome if the seeding runs would be stored in collection to prevent duplicates within the seeded collection. For example sequelize (mysql orm) is storing timestamp and file names in a separate table to prevent that.

Keep up the good work!

dominicrico avatar Feb 25 '20 21:02 dominicrico

Hi @dominicrico, thanks for the idea and kind words! That's good idea, I will consider it for future releases.

pkosiec avatar Feb 26 '20 17:02 pkosiec

@pkosiec I agree with @dominicrico this would be a great feature to add. Would you be open to a PR for this functionality? I'm not 100% sure how it could be implemented yet but looking at this line it seems like it would need changed to handle the duplicate case.

Edit: Setting the ordered param to false seems promising: https://stackoverflow.com/questions/61480444/mongodb-insertmany-and-skip-duplicates

ronan-f avatar May 31 '22 19:05 ronan-f

Hi @ronan-f 👋, sorry for a long delay.

Sure thing! The PR that implements this functionality is very welcome (as far as it is opt-in feature that doesn't break existing behavior) 🙂 Cheers!

pkosiec avatar Jun 19 '22 20:06 pkosiec