Class | Moped::Database |
In: |
lib/moped/database.rb
|
Parent: | Object |
The class for interacting with a MongoDB database. One only interacts with this class indirectly through a session.
@since 1.0.0
name | [R] |
@!attribute name
@return [ String ] The name of the database. @!attribute session @return [ Session ] The database session. |
session | [R] |
@!attribute name
@return [ String ] The name of the database. @!attribute session @return [ Session ] The database session. |
Initialize the database.
@example Initialize a database object.
Database.new(session, :artists)
@param [ Session ] session The session. @param [ String, Symbol ] name The name of the database.
@since 1.0.0
Get a collection by the provided name.
@example Get a collection.
session[:users]
@param [ Symbol, String ] collection The collection name.
@return [ Collection ] An instance of the collection.
@since 1.0.0
Get all non-system collection names from the database, this excludes indexes.
@example Get all the collection names.
database.collection_names
@return [ Array<String> ] The names of all collections.
@since 1.0.0
Get all non-system collections from the database.
@example Get all the collections.
database.collections
@return [ Array<Collection> ] All the collections.
@since 1.0.0
Log in with username and password on the current database.
@example Authenticate against the database.
session.login("user", "pass")
@param [ String ] username The username. @param [ String ] password The password.
@since 1.0.0