How to silently skip an error in "Ecto.insert_all"?

I use {ins_count, _} = Ecto.insert_all(...) to insert data provided by user. In my database there’s a unique constraint, and a user may accidentally attempt to insert one or multiple duplicates. Currently the database will raise an exception and therefore the whole function will fail.

However, what I want it to become is that it silently to raise, or rather skip, an exception in the cases of a duplicate, or duplicates. The function must not fail.

And ins_count to return the amount of the new records successfully inserted. It may also may be 0 if all the data happen to be a duplicate of the existing data in the DB.

How to do it?

I’m aware that there’s on_conflist, but which option should I use?

on_conflict: :nothing