Returns the names of the collections in this database.
Returns the names of the collections in this database.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.DefaultDB def listCollections(db: DefaultDB)( implicit ec: ExecutionContext): Future[List[String]] = db.collectionNames
Create the user with given properties.
Create the user with given properties.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.{ DefaultDB, ScramSha256Authentication, ScramSha1Authentication, WriteConcern } import reactivemongo.api.commands.UserRole def createReadWriteUser(db: DefaultDB, name: String)( implicit ec: ExecutionContext): Future[Unit] = db.createUser( user = name, pwd = None, // no initial password customData = None, // no custom data roles = List(UserRole("readWrite")), digestPassword = true, writeConcern = WriteConcern.Default, restrictions = List.empty, mechanisms = List( ScramSha1Authentication, ScramSha256Authentication))
the type of custom data associated with the created user
the name of the user to be created
the user password (not required if the database uses external credentials)
the custom data to associate with the user account
the roles granted to the user, possibly an empty to create users without roles
when true, the mongod instance will create the hash of the user password (default: true
)
the optional level of write concern
the authentication restriction
the authentication mechanisms (e.g. ScramSha1Authentication)
Drops this database.
Drops this database.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.DefaultDB def dropDB(db: DefaultDB)( implicit ec: ExecutionContext): Future[Unit] = db.drop()
Returns an index manager for this database.
Returns an index manager for this database.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.DefaultDB import reactivemongo.api.indexes.NSIndex def listIndexes(db: DefaultDB)( implicit ec: ExecutionContext): Future[List[String]] = db.indexesManager.list().map(_.flatMap { ni: NSIndex => ni.index.name.toList })
Tests if the server, resolved according to the given read preference, responds to commands.
Tests if the server, resolved according to the given read preference, responds to commands.
true if successful (even if the server is write locked)
MongoDB 3.0
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.DefaultDB def pingDB(db: DefaultDB)( implicit ec: ExecutionContext): Future[Boolean] = db.ping() // with default ReadPreference
Renames a collection.
Can only be executed if the this database reference is the admin
one.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.DefaultDB def addCollSuffix( admin: DefaultDB, coll: String, suffix: String)(implicit ec: ExecutionContext): Future[Unit] = admin.renameCollection("myDB", coll, coll + suffix).map(_ => {})
the name of the database where the collection exists with the current
name
the current name of the collection, in the specified db
the new name of this collection (inside the same db
)
If a collection of name to
already exists, then drops that collection before renaming this one.
a failure if the dropExisting option is false and the target collection already exists
(dBMetaCommands: StringAdd).self
(dBMetaCommands: StringFormat).self
(Since version 0.19.1) Use createUser
with DBMetaWriter
(Since version 0.18.4) Use createUser
with complete authentication options
Returns the server status.
Returns the server status.
(Since version 0.19.4) Will be removed (not maintained): use db.runCommand(BSONDocument("serverStatus" -> 1)
with custom reader
(dBMetaCommands: ArrowAssoc[DBMetaCommands]).x
(Since version 2.10.0) Use leftOfArrow
instead
(dBMetaCommands: Ensuring[DBMetaCommands]).x
(Since version 2.10.0) Use resultOfEnsuring
instead
A mixin that provides commands about this database itself.
(Since version 0.19.8) Internal: will be made private