class MongoBrowser::Models::Database
Attributes
mongo_db[R]
Public Class Methods
new(mongo_db)
click to toggle source
# File lib/mongo_browser/models/database.rb, line 6 def initialize(mongo_db) @mongo_db = mongo_db end
Public Instance Methods
collection(name)
click to toggle source
# File lib/mongo_browser/models/database.rb, line 27 def collection(name) Collection.new(mongo_db.collection(name)) end
collection_names()
click to toggle source
# File lib/mongo_browser/models/database.rb, line 23 def collection_names mongo_db.collection_names end
collections()
click to toggle source
# File lib/mongo_browser/models/database.rb, line 31 def collections collection_names.map { |name| collection(name) } end
count()
click to toggle source
# File lib/mongo_browser/models/database.rb, line 15 def count collections.count end
drop!()
click to toggle source
# File lib/mongo_browser/models/database.rb, line 39 def drop! mongo_db.connection.drop_database(self.name) end
name()
click to toggle source
# File lib/mongo_browser/models/database.rb, line 10 def name mongo_db.name end
Also aliased as: id
size()
click to toggle source
# File lib/mongo_browser/models/database.rb, line 19 def size info["sizeOnDisk"].to_i end
stats()
click to toggle source
# File lib/mongo_browser/models/database.rb, line 35 def stats mongo_db.stats end
Private Instance Methods
info()
click to toggle source
# File lib/mongo_browser/models/database.rb, line 45 def info @info ||= mongo_db.connection["admin"].command(listDatabases: true)["databases"].find do |db| db["name"] == self.name end end