23 lines
385 B
Ruby
23 lines
385 B
Ruby
#require 'rubygems' # not necessary for Ruby 1.9
|
|
require 'mongo'
|
|
|
|
Mongo::Logger.logger.level = ::Logger::FATAL
|
|
|
|
include Mongo
|
|
|
|
class MongoConnect
|
|
def initialize(dbname, collname)
|
|
@db = Mongo::Client.new(
|
|
["127.0.0.1:27017"],
|
|
:database => dbname)
|
|
@coll = @db[collname.to_sym]
|
|
end
|
|
|
|
def db()
|
|
return @db
|
|
end
|
|
|
|
def collection()
|
|
return @coll
|
|
end
|
|
end
|