Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mongodb and ruby driver

  • Loading branch information...
commit 2d213547cf9fda672e496f32fe40958d28635ce6 1 parent 76ea92a
José Carlos García authored
17 mongodb/mongodb1.rb
View
@@ -0,0 +1,17 @@
+require 'mongo'
+
+conn = Mongo::Connection.new
+db = conn.db("rubylearning")
+
+puts "Getting a list of collections..."
+db.collection_names.each { |name| puts name }
+
+# Getting a collection
+coll = db.collection("students")
+
+# Inserting a document
+doc = {:name => 'Manisha', :dob => Time.now, :loves => ['english', 'marathi'], :weight => 62, :gender => 'f', :country => 'india'}
+coll_id = coll.insert(doc)
+
+# Updating a document
+coll.update({:_id => coll_id}, '$set' => {:weight => 60})
2  rack_middleware/config.ru
View
@@ -1,3 +1,3 @@
require './my_middleware'
use MyMiddleware::Hello
-run Proc.new {|env| [200, {"Content-Type" => "text/plain"}, ['Try accessing visiting /hello']] }
+run Proc.new {|env| [200, {"Content-Type" => "text/plain"}, ['Try accessing visiting /hello']]}
2  stock_exchange_sinatra/Gemfile
View
@@ -0,0 +1,2 @@
+source "http://rubygems.org"
+gem "sinatra"
17 stock_exchange_sinatra/Gemfile.lock
View
@@ -0,0 +1,17 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ tilt (1.3.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ sinatra
Please sign in to comment.
Something went wrong with that request. Please try again.