You are here

public function MongodbCommands::mongodbFind in MongoDB 8.2

Execute a find() query against a collection.

@usage drush mongodb:find <collection> <query>... <query> is a single JSON selector in single string format. Quote it. @usage drush mongodb:find logger watchdog Get the logger/watchdog error-level templates @usage drush mo-find logger watchdog '{ "severity": 3 }' Get all the logger/watchdog entries tracking rows. @usage drush mdbf keyvalue kvp_state '{ "_id": "system.theme_engine.files" }' Get a specific State entry. Note how escaping needs to be performed in the shell.

@command mongodb:find @aliases mdbf,mo-find

Parameters

string $alias: The database alias.

string $collection: The collection name in the database.

string $selector: A MongoDB find() selector in JSON format. Defaults to '{}'.

array $options: A Drush-magic parameter enabling Drush to choose the output format.

Return value

array The matching documents, in array format.

File

modules/mongodb/src/Commands/MongodbCommands.php, line 84

Class

MongodbCommands
Drush 9 commands service for the mongodb module.

Namespace

Drupal\mongodb\Commands

Code

public function mongodbFind(string $alias, string $collection, string $selector = '{}', array $options = [
  'format' => 'yaml',
]) {
  return $this->tools
    ->find($alias, $collection, $selector);
}