Practical Ruby Projects with Mongo DB

Notes from the "Practical Ruby Projects" session at MongoSF
  • MongoDB doesn't have joins, if you want to do a join, you have to it yourself.
  • If scaling out is easy, who cares about the DB getting "too large"?
    • Why do I need to use less space and keep things in 3NF?
    • Who cares about saving space?  "I only care because MySQL is a pain to scale horizontally."
  • If you need db level transactions you shouldn't use Mongo?
  • I never use logs, but logs are only used when something goes wrong
  • Capped collection:
    • Fixed-size, auto-age out collections
    • Fixed insertion order
    • Super fast (faster than normal writes)
    • Ideal for logging and caching
  • bunyan - thin ruby layer around a MongoDB capped collection - http://github.com/ajsharp/bunyan
  • "I hate around filters"
  • Mongolytics - http://github.com/tpitale/mongolytics
  • db.posts.ensureIndex({'posts': 1})
  • db.posts.find({'tags.name': 'ruby'}) <== killer feature (search on properties of an array of embedded documents)
  • If you are going to go over the Mongo 4mb document object, use GridFS - http://www.mongodb.org/display/DOCS/GridFS+Specification
  • We use FactoryGirl for all our tests using MongoMapper - http://github.com/thoughtbot/factory_girl
  • Mongoid is another mongo ORM mapper that's similar to ActiveRecord