Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MongoDB and Ruby

Adam DeLong
December 02, 2013

MongoDB and Ruby

This was a talk I gave at the West Michigan Ruby Users Group (http://www.meetup.com/mi-ruby) on December 2nd, 2013. For more details, you can see this post here: http://blog.elevatorup.com/post/69788162450/mongodb-and-ruby

Adam DeLong

December 02, 2013

More Decks by Adam DeLong

Other Decks in Programming


  1. John Nunemaker GitHub, Gauges, Speaker Deck, Harmony App “Whereas SQL

    is about normalizing the storage of data and then flexibly querying it, NoSQL is about thinking how you will query data and then flexibly storing it.”
  2. Collections Not Tables db.users { Name: “John Doe”, Age: 35,

    Twitter: “@johndoe” }, { Name: “Jane Doe”, Age: 27, Twitter: “@janedoe” }
  3. Embedded Documents { Name: “John Doe”, Age: 35, Twitter: “@johndoe”,

    address: { street: “5555 Lane Rd” city: “Wonderland” zip-code: 55555 } }
  4. Mongo Shell $: mongo > use rug > rug.admins.insert({name: “John

    Doe”}) > rug.admins.find() > {_id: 1231232, name: “John Doe”} > rug.admins.find().count() > 1
  5. ODMs in a ORM World MongoMapper Mongoid Mongomatic MongoODM MongoModel

    High-level modeling functions > Validations > Associations Gems
  6. Embedded v. Linking Embedded Use “embeds_in” Included in one query

    Linking Use “has_many” Reference to parent in foreign key Requires another query
  7. #one query quiz = Quiz.find(1) quiz.questions >> returns questions []

    question = questions.first >> returns question answers = question.answers.first >> returns answer