-
-
Save yanmhlv/7813469 to your computer and use it in GitHub Desktop.
ruby and mongo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'Mongo' | |
include mongo | |
conn = MongoClient.new('192.168.1.103') | |
db = conn['test_database'] | |
coll = db['test_collection'] | |
coll.find.each do |x| | |
puts x['_id'].generation_time | |
end | |
puts conn.database_names | |
puts db.collection_names | |
auth = db.authenticate(username, password) | |
coll.insert({:name => 'MongoDB', :type => 'database', :count => 1, :info => {:x => 1, :y => 2}}) | |
puts coll.find_one | |
coll.find.each {|row| puts row.inspect } | |
coll.find.to_a | |
coll.find_one({:i => {'$gt' => 50}}, :fields => [:name, :type]) | |
coll.index_information |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment