Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-mack committed Jan 27, 2025
1 parent 8771d58 commit 2a498b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
13 changes: 5 additions & 8 deletions source/includes/run-command.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import org.bson.Document

fun main() {
//start-execute
val command = {
find: "restaurants",
filter: { cuisine: "Italian" },
projection: { name: 1, rating: 1, address: 1 },
sort: { name: 1 },
limit: 5
}
val commandResult = database.runCommand(command)
val explanation = database.runCommand({
explain: {
find: 'restaurants'
}
})
//end-execute

//start-read-preference
Expand Down
9 changes: 5 additions & 4 deletions source/run-command.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ To run a database command, specify the command and any relevant
parameters in a document, then pass the document to the ``runCommand()`` method.

The following code shows how you can use the ``runCommand()``
method to run the ``find`` command, which returns information about
the current member's role in the replica set, on a database:
method to run the ``explain`` command, which returns information about
how the specified CRUD command would be executed:

.. literalinclude:: /includes/run-command.kt
:start-after: start-execute
Expand Down Expand Up @@ -155,9 +155,10 @@ Additional Information

For more information about the concepts in this guide, see the following documentation:

- Kotlin API
- Kotlin Sync API
- `runCommand() <{+api+}/com.mongodb.kotlin.client/-mongo-database/run-command.html>`__
- Database
- :manual:`Database Commands </reference/command/>`
- :manual:`explain Command </reference/command/explain/>`
- :manual:`hello Command </reference/command/hello/>`
- :manual:`find Command </reference/command/find/>`
- :manual:`buildInfo Command </reference/command/buildInfo/#mongodb-dbcommand-dbcmd.buildInfo>`

0 comments on commit 2a498b5

Please sign in to comment.