Saturday, September 27, 2014

Testing MongoDB from sinatra

gem install mongo_kerberos

require 'mongo'
# require 'bson_ext'

include Mongo

MONGO_CLIENT = MongoClient.new # defaults to localhost:27017
# mongo_client = MongoClient.new("localhost", 27017)
# db = client['analytics-learning']

# coll = db['collection-scene-abc']

# CRUD
10.times { |i| coll.insert({ :count => i+1 }) }
puts “There are #collcoll.count total documents. Here they are:” coll.find.each { |doc| puts doc.inspect }
coll.update({ :count => 5 }, { :count => ‘foobar’ })

coll.remove({ :count => 8 }) coll.remove ```

No comments:

Post a Comment