首先通过RubyGem安装MongoDB驱动

gem install mongo

Ruby连接MongoDB

db = Mongo::Connection.new(“localhost”, 27017).db(“prefs”) 
locationCollection = db.collection(“location”)
locationCollection.find().each { |row| puts row.inspect }

results matching ""

    No results matching ""