Skip to content

Commit

Permalink
Mongodb and ruby driver
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarlosgarcia committed Mar 3, 2012
1 parent 76ea92a commit 2d21354
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
17 changes: 17 additions & 0 deletions mongodb/mongodb1.rb
Original file line number Original file line Diff line number Diff line change
@@ -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 changes: 1 addition & 1 deletion rack_middleware/config.ru
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,3 @@
require './my_middleware' require './my_middleware'
use MyMiddleware::Hello 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 changes: 2 additions & 0 deletions stock_exchange_sinatra/Gemfile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
source "http://rubygems.org"
gem "sinatra"
17 changes: 17 additions & 0 deletions stock_exchange_sinatra/Gemfile.lock
Original file line number Original file line Diff line number Diff line change
@@ -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

0 comments on commit 2d21354

Please sign in to comment.