runCommand

@JvmName(name = "runCommandDocument")
suspend fun runCommand(command: Bson, readPreference: ReadPreference = this.readPreference): Document

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

Return

the command result

Parameters

command

the command to be run

readPreference

the ReadPreference to be used when executing the command, defaults to MongoDatabase.readPreference


inline suspend fun <T : Any> runCommand(command: Bson, readPreference: ReadPreference = this.readPreference): T

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

Return

the command result

Parameters

T

the class to decode each document into

command

the command to be run

readPreference

the ReadPreference to be used when executing the command, defaults to MongoDatabase.readPreference


@JvmName(name = "runCommandDocumentWithSession")
suspend fun runCommand(clientSession: ClientSession, command: Bson, readPreference: ReadPreference = this.readPreference): Document

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

Return

the command result

Parameters

clientSession

the client session with which to associate this operation

command

the command to be run

readPreference

the ReadPreference to be used when executing the command, defaults to MongoDatabase.readPreference


inline suspend fun <T : Any> runCommand(clientSession: ClientSession, command: Bson, readPreference: ReadPreference = this.readPreference): T

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

Return

the command result

Parameters

T

the class to decode each document into

clientSession

the client session with which to associate this operation

command

the command to be run

readPreference

the ReadPreference to be used when executing the command, defaults to MongoDatabase.readPreference


suspend fun <T : Any> runCommand(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.

Return

the command result

Parameters

T

the class to decode each document into

command

the command to be run

readPreference

the ReadPreference to be used when executing the command, defaults to MongoDatabase.readPreference

resultClass

the target document class


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.

Return

the command result

Parameters

T

the class to decode each document into

clientSession

the client session with which to associate this operation

command

the command to be run

readPreference

the ReadPreference to be used when executing the command, defaults to MongoDatabase.readPreference

resultClass

the target document class