Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No efficient way of counting? #28

Closed
johnjcamilleri opened this issue Feb 27, 2019 · 2 comments
Closed

No efficient way of counting? #28

johnjcamilleri opened this issue Feb 27, 2019 · 2 comments

Comments

@johnjcamilleri
Copy link
Contributor

johnjcamilleri commented Feb 27, 2019

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?

@tiaguinho
Copy link
Owner

Hi @johnjcamilleri, can you open a PR with this change so I can merge with the master of the project?

Thanks!

@tiaguinho
Copy link
Owner

Thank you for your contribution @johnjcamilleri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants