MongoDatabase

class MongoDatabase(wrapped: MongoDatabase)

The MongoDatabase representation.

Constructors

Link copied to clipboard
constructor(wrapped: MongoDatabase)

Functions

Link copied to clipboard
@JvmName(name = "aggregateAsDocument")
fun aggregate(pipeline: List<Bson>): AggregateFlow<Document>
inline fun <T : Any> aggregate(pipeline: List<Bson>): AggregateFlow<T>
@JvmName(name = "aggregateAsDocumentWithSession")
fun aggregate(clientSession: ClientSession, pipeline: List<Bson>): AggregateFlow<Document>
inline fun <T : Any> aggregate(clientSession: ClientSession, pipeline: List<Bson>): AggregateFlow<T>
fun <T : Any> aggregate(pipeline: List<Bson>, resultClass: Class<T>): AggregateFlow<T>
fun <T : Any> aggregate(clientSession: ClientSession, pipeline: List<Bson>, resultClass: Class<T>): AggregateFlow<T>

Runs an aggregation framework pipeline on the database for pipeline stages that do not require an underlying collection, such as $currentOp and $listLocalSessions.

Link copied to clipboard
suspend fun createCollection(collectionName: String, createCollectionOptions: CreateCollectionOptions = CreateCollectionOptions())
suspend fun createCollection(clientSession: ClientSession, collectionName: String, createCollectionOptions: CreateCollectionOptions = CreateCollectionOptions())

Create a new collection with the selected options

Link copied to clipboard
suspend fun createView(viewName: String, viewOn: String, pipeline: List<Bson>, createViewOptions: CreateViewOptions = CreateViewOptions())
suspend fun createView(clientSession: ClientSession, viewName: String, viewOn: String, pipeline: List<Bson>, createViewOptions: CreateViewOptions = CreateViewOptions())

Creates a view with the given name, backing collection/view name, aggregation pipeline, and options that defines the view.

Link copied to clipboard
suspend fun drop()
suspend fun drop(clientSession: ClientSession)

Drops this database.

Link copied to clipboard
inline fun <T : Any> getCollection(collectionName: String): MongoCollection<T>
fun <T : Any> getCollection(collectionName: String, resultClass: Class<T>): MongoCollection<T>

Gets a collection.

Link copied to clipboard
fun listCollectionNames(clientSession: ClientSession): Flow<String>

Gets the names of all the collections in this database.

Link copied to clipboard
@JvmName(name = "listCollectionsAsDocument")
fun listCollections(): ListCollectionsFlow<Document>
@JvmName(name = "listCollectionsAsDocumentWithSession")
fun listCollections(clientSession: ClientSession): ListCollectionsFlow<Document>
inline fun <T : Any> listCollections(clientSession: ClientSession): ListCollectionsFlow<T>
fun <T : Any> listCollections(resultClass: Class<T>): ListCollectionsFlow<T>
fun <T : Any> listCollections(clientSession: ClientSession, resultClass: Class<T>): ListCollectionsFlow<T>

Gets all the collections in this database.

Link copied to clipboard
@JvmName(name = "runCommandDocument")
suspend fun runCommand(command: Bson, readPreference: ReadPreference = this.readPreference): Document
inline suspend fun <T : Any> runCommand(command: Bson, readPreference: ReadPreference = this.readPreference): T
@JvmName(name = "runCommandDocumentWithSession")
suspend fun runCommand(clientSession: ClientSession, command: Bson, readPreference: ReadPreference = this.readPreference): Document
inline suspend fun <T : Any> runCommand(clientSession: ClientSession, command: Bson, readPreference: ReadPreference = this.readPreference): T
suspend fun <T : Any> runCommand(command: Bson, readPreference: ReadPreference = this.readPreference, resultClass: Class<T>): T
suspend fun <T : Any> runCommand(clientSession: ClientSession, command: Bson, readPreference: ReadPreference = this.readPreference, resultClass: Class<T>): T

Executes the given command in the context of the current database with the given read preference.

Link copied to clipboard
@JvmName(name = "watchAsDocument")
fun watch(pipeline: List<Bson> = emptyList()): ChangeStreamFlow<Document>
inline fun <T : Any> watch(pipeline: List<Bson> = emptyList()): ChangeStreamFlow<T>
@JvmName(name = "watchAsDocumentWithSession")
fun watch(clientSession: ClientSession, pipeline: List<Bson> = emptyList()): ChangeStreamFlow<Document>
inline fun <T : Any> watch(clientSession: ClientSession, pipeline: List<Bson> = emptyList()): ChangeStreamFlow<T>
fun <T : Any> watch(pipeline: List<Bson> = emptyList(), resultClass: Class<T>): ChangeStreamFlow<T>
fun <T : Any> watch(clientSession: ClientSession, pipeline: List<Bson> = emptyList(), resultClass: Class<T>): ChangeStreamFlow<T>

Creates a change stream for this database.

Link copied to clipboard
fun withCodecRegistry(newCodecRegistry: CodecRegistry): MongoDatabase

Create a new MongoDatabase instance with a different codec registry.

Link copied to clipboard
fun withReadConcern(newReadConcern: ReadConcern): MongoDatabase

Create a new MongoDatabase instance with a different read concern.

Link copied to clipboard
fun withReadPreference(newReadPreference: ReadPreference): MongoDatabase

Create a new MongoDatabase instance with a different read preference.

Link copied to clipboard
fun withWriteConcern(newWriteConcern: WriteConcern): MongoDatabase

Create a new MongoDatabase instance with a different write concern.

Properties

Link copied to clipboard
val codecRegistry: CodecRegistry

The codec registry for the database.

Link copied to clipboard

The name of the database.

Link copied to clipboard
val readConcern: ReadConcern

The read concern for the database.

Link copied to clipboard
val readPreference: ReadPreference

The read preference for the database.

Link copied to clipboard
val writeConcern: WriteConcern

The write concern for the database.