Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Members list
Type members
Value members
Abstract methods
Creates the given index.
Creates the given index.
import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.collections.GenericCollection
import reactivemongo.api.indexes.Index
def createIndexes(
coll: GenericCollection[_], is: Seq[Index.Default])(
implicit ec: ExecutionContext): Future[Unit] =
Future.sequence(
is.map(idx => coll.indexesManager.create(idx))).map(_ => {})
Warning: given the options you choose, and the data to index, it can be a long and blocking operation on the database. You should really consider reading http://www.mongodb.org/display/DOCS/Indexes before doing this, especially in production.
Attributes
- index
the index to create
Drops the given index on that collection.
Drops the given index on that collection.
import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.collections.GenericCollection
def dropIndex(coll: GenericCollection[_], name: String)(
implicit ec: ExecutionContext): Future[Int] =
coll.indexesManager.drop(name)
Attributes
- indexName
the name of the index to be dropped
- Returns:
The number of indexes that were dropped.
Drops all the indexes on that collection.
Drops all the indexes on that collection.
import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.collections.GenericCollection
def dropAllIndexes(coll: GenericCollection[_])(
implicit ec: ExecutionContext): Future[Int] =
coll.indexesManager.dropAll()
Attributes
- Returns:
The number of indexes that were dropped.
Creates the given index only if it does not exist on this collection.
Creates the given index only if it does not exist on this collection.
The following rules are used to check the matching index:
- if
nsIndex.isDefined
, it checks using the index name, - otherwise it checks using the key.
import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.collections.GenericCollection
import reactivemongo.api.indexes.Index
def ensureIndexes(
coll: GenericCollection[_], is: Seq[Index.Default])(
implicit ec: ExecutionContext): Future[Unit] =
Future.sequence(
is.map(idx => coll.indexesManager.ensure(idx))).map(_ => {})
Warning: given the options you choose, and the data to index, it can be a long and blocking operation on the database. You should really consider reading http://www.mongodb.org/display/DOCS/Indexes before doing this, especially in production.
Attributes
- index
the index to create
- Returns:
true if the index was created, false if it already exists.
Lists the indexes for the current collection.
Lists the indexes for the current collection.
import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.collections.GenericCollection
def listIndexes(coll: GenericCollection[_])(
implicit ec: ExecutionContext): Future[List[String]] =
coll.indexesManager.list().map(_.flatMap { idx =>
idx.name.toList
})