GenericMongoCollection

mongo4cats.collection.GenericMongoCollection
abstract class GenericMongoCollection[F[_], T, S[_]]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def aggregate[Y : ClassTag](pipeline: Seq[Bson]): AggregateQueryBuilder[F, Y, S]

Aggregates documents according to the specified aggregation pipeline. http://docs.mongodb.org/manual/aggregation/

Aggregates documents according to the specified aggregation pipeline. http://docs.mongodb.org/manual/aggregation/

Value parameters

pipeline

the aggregate pipeline

Attributes

def aggregate[Y : ClassTag](pipeline: Aggregate): AggregateQueryBuilder[F, Y, S]
def aggregate[Y : ClassTag](session: ClientSession[F], pipeline: Aggregate): AggregateQueryBuilder[F, Y, S]
def as[Y : ClassTag]: GenericMongoCollection[F, Y, S]
def bulkWrite[T1 <: T](commands: Seq[WriteCommand[T1]], options: BulkWriteOptions): F[BulkWriteResult]

Executes a mix of inserts, updates, replaces, and deletes.

Executes a mix of inserts, updates, replaces, and deletes.

https://docs.mongodb.com/manual/reference/method/db.collection.bulkWrite/

Value parameters

commands

the writes to execute

options

the options to apply to the bulk write operation

Attributes

def bulkWrite[T1 <: T](cs: ClientSession[F], commands: Seq[WriteCommand[T1]], options: BulkWriteOptions): F[BulkWriteResult]
def count(filter: Bson, options: CountOptions): F[Long]

Counts the number of documents in the collection according to the given options.

Counts the number of documents in the collection according to the given options.

Value parameters

filter

the query filter

options

the options describing the count

Attributes

Since

2.4

def count(session: ClientSession[F], filter: Filter, options: CountOptions): F[Long]
def createIndex(key: Bson, options: IndexOptions): F[String]

Value parameters

key

an object describing the index key(s). This can be of any type for which a Codec is registered

options

the options for the index

Attributes

def createIndex(session: ClientSession[F], index: Index, options: IndexOptions): F[String]
def deleteMany(filter: Bson, options: DeleteOptions): F[DeleteResult]

Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.

Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.

Value parameters

filter

the query filter to apply the the delete operation

options

the options to apply to the delete operation @since 1.2

Attributes

def deleteMany(session: ClientSession[F], filter: Filter, options: DeleteOptions): F[DeleteResult]
def deleteOne(filter: Bson, options: DeleteOptions): F[DeleteResult]

Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.

Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.

Value parameters

filter

the query filter to apply the the delete operation

options

the options to apply to the delete operation @since 1.2

Attributes

def deleteOne(session: ClientSession[F], filter: Filter, options: DeleteOptions): F[DeleteResult]
def distinct[Y : ClassTag](fieldName: String, filter: Bson): DistinctQueryBuilder[F, Y, S]

Gets the distinct values of the specified field name.

Gets the distinct values of the specified field name.

http://docs.mongodb.org/manual/reference/command/distinct/

Value parameters

fieldName

the field name

filter

the query filter

Attributes

def distinct[Y : ClassTag](session: ClientSession[F], fieldName: String, filter: Filter): DistinctQueryBuilder[F, Y, S]
def drop: F[Unit]

Drops this collection from the Database.

Drops this collection from the Database.

http://docs.mongodb.org/manual/reference/command/drop/

Attributes

def drop(session: ClientSession[F]): F[Unit]
def dropIndex(name: String, options: DropIndexOptions): F[Unit]

Drops the given index.

Value parameters

name

the name of the index to remove

options

options to use when dropping indexes

Attributes

def dropIndex(session: ClientSession[F], name: String, options: DropIndexOptions): F[Unit]
def dropIndex(keys: Bson, options: DropIndexOptions): F[Unit]

Drops the index given the keys used to create it.

Drops the index given the keys used to create it.

Value parameters

keys

the keys of the index to remove

options

options to use when dropping indexes

Attributes

Since

2.2

def dropIndex(session: ClientSession[F], index: Index, options: DropIndexOptions): F[Unit]
def dropIndexes(options: DropIndexOptions): F[Unit]

Drop all the indexes on this collection, except for the default on _id.

Drop all the indexes on this collection, except for the default on _id.

http://docs.mongodb.org/manual/reference/command/dropIndexes/

Value parameters

options

options to use when dropping indexes

Attributes

Since

2.2

def dropIndexes(session: ClientSession[F], options: DropIndexOptions): F[Unit]
def find(filter: Bson): FindQueryBuilder[F, T, S]

Finds matching documents in the collection.

Finds matching documents in the collection.

http://docs.mongodb.org/manual/tutorial/query-documents/

Value parameters

filter

the query filter

Attributes

def find(session: ClientSession[F], filter: Filter): FindQueryBuilder[F, T, S]
def findOneAndDelete(filter: Bson, options: FindOneAndDeleteOptions): F[Option[T]]

Atomically find a document and remove it.

Atomically find a document and remove it.

Value parameters

filter

the query filter to find the document with

options

the options to apply to the operation

Attributes

Note

If no documents matched the query filter, then None will be returned

def findOneAndDelete(session: ClientSession[F], filter: Filter, options: FindOneAndDeleteOptions): F[Option[T]]
def findOneAndReplace(filter: Bson, replacement: T, options: FindOneAndReplaceOptions): F[Option[T]]

Atomically find a document and replace it.

Atomically find a document and replace it.

Value parameters

filter

the query filter to apply the the replace operation

options

the options to apply to the operation

replacement

the replacement document

Attributes

Note

Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then None will be returned

def findOneAndReplace(session: ClientSession[F], filter: Filter, replacement: T, options: FindOneAndReplaceOptions): F[Option[T]]
def findOneAndUpdate(filter: Bson, update: Bson, options: FindOneAndUpdateOptions): F[Option[T]]

Atomically find a document and update it.

Atomically find a document and update it.

Value parameters

filter

a document describing the query filter. This can be of any type for which a Codec is registered

options

the options to apply to the operation

update

a document describing the update. The update to apply must include only update operators. This can be of any type for which a Codec is registered

Attributes

Note

Depending on the value of the returnOriginal property, this will either be the document as it was before the update or as it is after the update. If no documents matched the query filter, then None will be returned

def findOneAndUpdate(session: ClientSession[F], filter: Filter, update: Update, options: FindOneAndUpdateOptions): F[Option[T]]
def insertMany(documents: Seq[T], options: InsertManyOptions): F[InsertManyResult]

Inserts a batch of documents. The preferred way to perform bulk inserts is to use the BulkWrite API. However, when talking with a server < 2.6, using this method will be faster due to constraints in the bulk API related to error handling.

Inserts a batch of documents. The preferred way to perform bulk inserts is to use the BulkWrite API. However, when talking with a server < 2.6, using this method will be faster due to constraints in the bulk API related to error handling.

Value parameters

documents

the documents to insert

options

the options to apply to the operation

Attributes

def insertMany(session: ClientSession[F], documents: Seq[T], options: InsertManyOptions): F[InsertManyResult]
def insertOne(document: T, options: InsertOneOptions): F[InsertOneResult]

Inserts the provided document. If the document is missing an identifier, the driver should generate one.

Inserts the provided document. If the document is missing an identifier, the driver should generate one.

Value parameters

document

the document to insert

options

the options to apply to the operation @since 1.1

Attributes

def insertOne(session: ClientSession[F], document: T, options: InsertOneOptions): F[InsertOneResult]
def listIndexes(session: ClientSession[F]): F[Iterable[Document]]

Get all the indexes in this collection.

Get all the indexes in this collection.

http://docs.mongodb.org/manual/reference/command/listIndexes

Value parameters

session

the client session with which to associate this operation

Attributes

def listIndexes[Y : ClassTag]: F[Iterable[Y]]
def listIndexes: F[Iterable[Document]]
def listIndexes[Y : ClassTag](cs: ClientSession[F]): F[Iterable[Y]]
def renameCollection(target: MongoNamespace, options: RenameCollectionOptions): F[Unit]

Rename the collection with oldCollectionName to the newCollectionName.

Rename the collection with oldCollectionName to the newCollectionName.

https://docs.mongodb.com/manual/reference/method/db.collection.renameCollection/

Value parameters

options

the options for renaming a collection

target

the name the collection will be renamed to

Attributes

def renameCollection(session: ClientSession[F], target: MongoNamespace, options: RenameCollectionOptions): F[Unit]
def replaceOne(filter: Bson, replacement: T, options: ReplaceOptions): F[UpdateResult]

Replace a document in the collection according to the specified arguments.

Replace a document in the collection according to the specified arguments.

http://docs.mongodb.org/manual/tutorial/modify-documents/#replace-the-document

Value parameters

filter

the query filter to apply the the replace operation

options

the options to apply to the replace operation

replacement

the replacement document

Attributes

def replaceOne(session: ClientSession[F], filter: Filter, replacement: T, options: ReplaceOptions): F[UpdateResult]
def underlying: MongoCollection[T]
def updateMany(filter: Bson, update: Bson, options: UpdateOptions): F[UpdateResult]

Update all documents in the collection according to the specified arguments.

Update all documents in the collection according to the specified arguments.

http://docs.mongodb.org/manual/tutorial/modify-documents/ http://docs.mongodb.org/manual/reference/operator/update/

Value parameters

filter

a document describing the query filter. This can be of any type for which a Codec is registered

options

the options to apply to the update operation

update

a document describing the update. The update to apply must include only update operators. This can be of any type for which a Codec is registered

Attributes

def updateMany(session: ClientSession[F], filter: Filter, update: Update, options: UpdateOptions): F[UpdateResult]
def updateMany(filter: Bson, update: Seq[Bson], options: UpdateOptions): F[UpdateResult]

Update all documents in the collection according to the specified arguments.

Update all documents in the collection according to the specified arguments.

http://docs.mongodb.org/manual/tutorial/modify-documents/ http://docs.mongodb.org/manual/reference/operator/update/

Value parameters

filter

a document describing the query filter. This can be of any type for which a Codec is registered

options

the options to apply to the update operation

update

a pipeline describing the update.

Attributes

Since

2.7

Note

Requires MongoDB 4.2 or greater

def updateOne(filter: Bson, update: Bson, options: UpdateOptions): F[UpdateResult]

Update a single document in the collection according to the specified arguments.

Update a single document in the collection according to the specified arguments.

http://docs.mongodb.org/manual/tutorial/modify-documents/ http://docs.mongodb.org/manual/reference/operator/update/

Value parameters

filter

a document describing the query filter. This can be of any type for which a Codec is registered

options

the options to apply to the update operation

update

a document describing the update. The update to apply must include only update operators. This can be of any type for which a Codec is registered

Attributes

def updateOne(session: ClientSession[F], filter: Filter, update: Update, options: UpdateOptions): F[UpdateResult]
def updateOne(filter: Bson, update: Seq[Bson], options: UpdateOptions): F[UpdateResult]

Update a single document in the collection according to the specified arguments.

Update a single document in the collection according to the specified arguments.

http://docs.mongodb.org/manual/tutorial/modify-documents/ http://docs.mongodb.org/manual/reference/operator/update/

Value parameters

filter

a document describing the query filter. This can be of any type for which a Codec is registered

options

the options to apply to the update operation

update

a pipeline describing the update.

Attributes

Since

2.7

Note

Requires MongoDB 4.2 or greater

def watch(pipeline: Seq[Bson]): WatchQueryBuilder[F, Document, S]

Creates a change stream for this collection.

Creates a change stream for this collection.

Value parameters

pipeline

the aggregation pipeline to apply to the change stream

Attributes

Since

2.2

Note

Requires MongoDB 3.6 or greater

def watch(pipeline: Aggregate): WatchQueryBuilder[F, Document, S]
def watch(session: ClientSession[F], pipeline: Aggregate): WatchQueryBuilder[F, Document, S]
def withAddedCodec(codecRegistry: CodecRegistry): GenericMongoCollection[F, T, S]
def withReadConcern(readConcern: ReadConcern): GenericMongoCollection[F, T, S]
def withReadPreference(readPreference: ReadPreference): GenericMongoCollection[F, T, S]
def withWriteConcern(writeConcert: WriteConcern): GenericMongoCollection[F, T, S]

Concrete methods

def aggregateWithCodec[Y : MongoCodecProvider](pipeline: Seq[Bson]): AggregateQueryBuilder[F, Y, S]
def aggregateWithCodec[Y : MongoCodecProvider](pipeline: Aggregate): AggregateQueryBuilder[F, Y, S]
def aggregateWithCodec[Y : MongoCodecProvider](session: ClientSession[F], pipeline: Aggregate): AggregateQueryBuilder[F, Y, S]
def bulkWrite[T1 <: T](commands: Seq[WriteCommand[T1]]): F[BulkWriteResult]
def bulkWrite[T1 <: T](cs: ClientSession[F], commands: Seq[WriteCommand[T1]]): F[BulkWriteResult]
def codecs: CodecRegistry
def count(filter: Filter, options: CountOptions): F[Long]
def count(filter: Bson): F[Long]
def count(filter: Filter): F[Long]
def count(session: ClientSession[F], filter: Filter): F[Long]
def count: F[Long]

Counts the number of documents in the collection.

Counts the number of documents in the collection.

Attributes

Since

2.4

def count(session: ClientSession[F]): F[Long]
def createIndex(index: Index, options: IndexOptions): F[String]
def createIndex(key: Bson): F[String]
def createIndex(index: Index): F[String]
def createIndex(session: ClientSession[F], index: Index): F[String]
def deleteMany(filter: Filter, options: DeleteOptions): F[DeleteResult]
def deleteMany(filters: Bson): F[DeleteResult]
def deleteMany(filters: Filter): F[DeleteResult]
def deleteMany(session: ClientSession[F], filters: Filter): F[DeleteResult]
def deleteOne(filter: Filter, options: DeleteOptions): F[DeleteResult]
def deleteOne(filters: Bson): F[DeleteResult]
def deleteOne(filter: Filter): F[DeleteResult]
def deleteOne(session: ClientSession[F], filter: Filter): F[DeleteResult]
def distinct[Y : ClassTag](fieldName: String, filter: Filter): DistinctQueryBuilder[F, Y, S]
def distinct[Y : ClassTag](fieldName: String): DistinctQueryBuilder[F, Y, S]

Gets the distinct values of the specified field name.

Gets the distinct values of the specified field name.

http://docs.mongodb.org/manual/reference/command/distinct/Distinct

Value parameters

fieldName

the field name

Attributes

def distinct[Y : ClassTag](session: ClientSession[F], fieldName: String): DistinctQueryBuilder[F, Y, S]
def distinctWithCodec[Y : ClassTag](fieldName: String, filter: Bson): DistinctQueryBuilder[F, Y, S]
def distinctWithCodec[Y : ClassTag](fieldName: String, filter: Filter): DistinctQueryBuilder[F, Y, S]
def distinctWithCodec[Y : ClassTag](session: ClientSession[F], fieldName: String, filter: Filter): DistinctQueryBuilder[F, Y, S]
def distinctWithCodec[Y : ClassTag](fieldName: String): DistinctQueryBuilder[F, Y, S]
def distinctWithCodec[Y : ClassTag](session: ClientSession[F], fieldName: String): DistinctQueryBuilder[F, Y, S]
def documentClass: Class[T]
def dropIndex(name: String): F[Unit]
def dropIndex(session: ClientSession[F], name: String): F[Unit]
def dropIndex(index: Index, options: DropIndexOptions): F[Unit]
def dropIndex(keys: Bson): F[Unit]
def dropIndex(index: Index): F[Unit]
def dropIndex(session: ClientSession[F], index: Index): F[Unit]
def dropIndexes: F[Unit]
def dropIndexes(session: ClientSession[F]): F[Unit]
def find(filter: Filter): FindQueryBuilder[F, T, S]
def find: FindQueryBuilder[F, T, S]

Finds all documents in the collection.

Finds all documents in the collection.

http://docs.mongodb.org/manual/tutorial/query-documents/

Attributes

def find(session: ClientSession[F]): FindQueryBuilder[F, T, S]
def findOneAndDelete(filter: Filter, options: FindOneAndDeleteOptions): F[Option[T]]
def findOneAndDelete(filter: Bson): F[Option[T]]
def findOneAndDelete(filter: Filter): F[Option[T]]
def findOneAndDelete(session: ClientSession[F], filter: Filter): F[Option[T]]
def findOneAndReplace(filter: Filter, replacement: T, options: FindOneAndReplaceOptions): F[Option[T]]
def findOneAndReplace(filter: Bson, replacement: T): F[Option[T]]
def findOneAndReplace(filter: Filter, replacement: T): F[Option[T]]
def findOneAndReplace(session: ClientSession[F], filter: Filter, replacement: T): F[Option[T]]
def findOneAndUpdate(filter: Filter, update: Update, options: FindOneAndUpdateOptions): F[Option[T]]
def findOneAndUpdate(filter: Bson, update: Bson): F[Option[T]]
def findOneAndUpdate(filter: Filter, update: Update): F[Option[T]]
def findOneAndUpdate(session: ClientSession[F], filter: Filter, update: Update): F[Option[T]]
def insertMany(documents: Seq[T]): F[InsertManyResult]
def insertMany(session: ClientSession[F], documents: Seq[T]): F[InsertManyResult]
def insertOne(document: T): F[InsertOneResult]
def insertOne(session: ClientSession[F], document: T): F[InsertOneResult]
def readConcern: ReadConcern
def readPreference: ReadPreference
def renameCollection(target: MongoNamespace): F[Unit]
def renameCollection(session: ClientSession[F], target: MongoNamespace): F[Unit]
def replaceOne(filter: Filter, replacement: T, options: ReplaceOptions): F[UpdateResult]
def replaceOne(filters: Bson, replacement: T): F[UpdateResult]
def replaceOne(filters: Filter, replacement: T): F[UpdateResult]
def replaceOne(session: ClientSession[F], filters: Filter, replacement: T): F[UpdateResult]
def updateMany(filter: Filter, update: Update, options: UpdateOptions): F[UpdateResult]
def updateMany(filters: Bson, update: Bson): F[UpdateResult]
def updateMany(filters: Filter, update: Update): F[UpdateResult]
def updateMany(session: ClientSession[F], filter: Filter, update: Update): F[UpdateResult]
def updateOne(filter: Filter, update: Update, options: UpdateOptions): F[UpdateResult]
def updateOne(filters: Bson, update: Bson): F[UpdateResult]
def updateOne(filters: Filter, update: Update): F[UpdateResult]
def updateOne(session: ClientSession[F], filters: Filter, update: Update): F[UpdateResult]
def updateOne(filters: Bson, update: Seq[Bson]): F[UpdateResult]
def watch: WatchQueryBuilder[F, Document, S]

Creates a change stream for this collection.

Creates a change stream for this collection.

Attributes

Since

2.2

Note

Requires MongoDB 3.6 or greater

def watch(session: ClientSession[F]): WatchQueryBuilder[F, Document, S]
def withAddedCodec[Y](implicit classTag: ClassTag[Y], cp: MongoCodecProvider[Y]): GenericMongoCollection[F, T, S]
protected def withNewDocumentClass[Y : ClassTag](coll: MongoCollection[T]): MongoCollection[Y]
def writeConcern: WriteConcern