pkosiec / mongo-seeding

🌱 The ultimate solution for populating your MongoDB database.
MIT License
554 stars 48 forks source link

Prevent duplicates while seeding #104

Open dominicrico opened 4 years ago

dominicrico commented 4 years ago

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!

pkosiec commented 4 years ago

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

ronan-f commented 2 years ago

@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

pkosiec commented 2 years ago

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!