Permalink
Browse files

Using MongoHQ

  • Loading branch information...
1 parent 2d21354 commit 59a8cd610c95627c74ab80316832ab8607c9e9a0 @jcarlosgarcia committed Mar 3, 2012
Showing with 18 additions and 0 deletions.
  1. +18 −0 mongodb/mongodb2.rb
View
@@ -0,0 +1,18 @@
+require 'mongo'
+
+db = Mongo::Connection.new('flame.mongohq.com', 27107).db("contacts")
+auth = db.authenticate(ARGV[0], ARGV[1])
+
+coll = db.collection("contacts")
+
+# Inserting a document
+docs = [{:name => 'Manisha', :loves => ['english', 'marathi'], :gender => 'f', :country => 'india'},
+ {:name => 'Satoshi', :loves => ['ruby','c'], :gender => 'm', :country => 'japan'},
+ {:name => 'Michael', :loves => ['ruby','clojure'], :gender => 'm', :country => 'austria'}]
+
+docs.each { |doc| coll.insert(doc) }
+
+puts "#{coll.count} docs inserted"
+
+coll.find.each { |doc| puts doc.inspect}
+

0 comments on commit 59a8cd6

Please sign in to comment.