design of bulk UPSERT (aka MERGE): update_or_insert

Stack Overflow and various forums are rife with questions about how to efficiently update or insert ActiveRecords into a table. (In fact, one of my earliest questions to this forum was on this very topic.)

My recent work regularly calls for an efficient "update or insert" method for tens of thousands of records. After a fair amount of googling, I don't see a generalized solution, so I've decided to design and implement the function for real. In this note, I'm proposing a design specifically for critique and feedback.

(First question: are there other forums where I should be posing this question?)

A typical use case might look like this:

hey ff,

You might want to take a look at https://github.com/seamusabshere/upsert - released same week you posted this.

Best, Seamus

Hello there I am not familiar with MongoDB but i think here is a possible resource. hope it will help you...