back

Mongoid's delete_all is way too epic

What do you think the below code would do in Mongoid?

1
2
3
4
5


Post.where(:author_id => 8).delete_all


It would delete all the posts where the author ID is 8, right? Right? Riiight? WRONG! FOOL! IT DELETES THE ENTIRE FUCKING POSTS COLLECTION. No joke.

Whereas in ActiveRecord Post.where(:author_id => 8).delete_all would delete ONLY THE POSTS WITH AUTHOR ID 8, Mongoid decided to JUST REMOVE THE ENTIRE COLLECTION. AWESOME SURPRISE!!!!!!!

This leads to awesomeness and unicorns when done in production.

October 27, 2010