I wanted an equivalent of Mongo's count command, which can return a result count without having to perform an actual find (which can be much slower). I couldn't find it in this library, so I hacked together this, added to src/ORM/Table.php:
/**
* count documents
*
* @param array $options
* @return int
* @access public
*/
public function count($options = [])
{
$query = new MongoFinder($this->__getCollection(), $options);
return $query->connection()->count();
}
Not sure if I've missed something, seems like this functionality should be standard?
I wanted an equivalent of Mongo's
count
command, which can return a result count without having to perform an actual find (which can be much slower). I couldn't find it in this library, so I hacked together this, added to src/ORM/Table.php:Not sure if I've missed something, seems like this functionality should be standard?