/** * Get a document from the database as an array. * * @param string $collection_name name of the collection * @param array $query a MongoDB query * @return array */ public function get($collection_name, $query) { if (!is_array($query)) { throw new \Exception("\$query must be an associative array of 'field => value' pairs"); } $collection = new Collection($collection_name, true, $this); return $collection->findOne($query); }