Sha256: 9c7edc8f811f0f37e1b490b29e940fe9b622de0f3068d65fa2c71a8e5f3b50b8
Contents?: true
Size: 922 Bytes
Versions: 2
Compression:
Stored size: 922 Bytes
Contents
module MongoBrowser module Models class Database attr_reader :mongo_db def initialize(mongo_db) @mongo_db = mongo_db end def name mongo_db.name end alias :id :name def count collections.count end def size info["sizeOnDisk"].to_i end def collection_names mongo_db.collection_names end def collection(name) Collection.new(mongo_db.collection(name)) end def collections collection_names.map { |name| collection(name) } end def stats mongo_db.stats end def drop! mongo_db.connection.drop_database(self.name) end private def info @info ||= mongo_db.connection["admin"].command(listDatabases: true)["databases"].find do |db| db["name"] == self.name end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongo_browser-0.2.5 | lib/mongo_browser/models/database.rb |
mongo_browser-0.2.0.rc2 | lib/mongo_browser/models/database.rb |