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

count's performance problem #10

Open
reasonMix opened this issue Feb 19, 2017 · 2 comments
Open

count's performance problem #10

reasonMix opened this issue Feb 19, 2017 · 2 comments

Comments

@reasonMix
Copy link

i reference the mongodb's c driver,query the collection's count,can use the 'count' command,but in your driver use the query and get the length of the documents for this,maybe this is a performance problem

@cyrilis
Copy link
Owner

cyrilis commented Feb 19, 2017

Hi @reasonMix ,
You can use count method in Cursor, it use count command to query the count of documents.
like this:

local postsCollection = db:collection("posts")
postsCollection:find({posted = true}):count(function(count) 
    p(count)
end)

I'll fix count method in db:count later (I must forget to refactor this.).

@reasonMix
Copy link
Author

@cyrilis OK

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