These are chat archives for Automattic/mongoose

2nd
Mar 2018
fredski02
@fredski02
Mar 02 2018 10:19
is there a way to get stats on a collection in mongoose?
for example, i dont want to have to do a findall on a posts collection if all i want to do is get the total number of posts
Juha Lindstedt
@pakastin
Mar 02 2018 10:26
.count()
fredski02
@fredski02
Mar 02 2018 10:32
yeah just seen that too. i guess thats probably the most efficient mongodb call i can make right?
Juha Lindstedt
@pakastin
Mar 02 2018 12:49
Yeah, for counting documents I believe so..
Returns the count of documents that would match a find() query for the collection or view. The db.collection.count() method does not perform the find() operation but instead counts and returns the number of results that match a query.
https://docs.mongodb.com/manual/reference/method/db.collection.count/
Mattious
@Mattious
Mar 02 2018 14:29
Hi @lineus thanks for your response. It solves my issue. Thanks a lot
Kev
@lineus
Mar 02 2018 15:11
@Mattious I learned as much from it as you did, probably more. I had never heard of cosmodb, so thanks for asking! glad I could help find the answer.
Mattious
@Mattious
Mar 02 2018 17:15
Hello i have one question about mongoose disciminator. I wabt to know if it has a performance impact. I search a solution to limit cost of cosmodb wherr you pay by collection. Better to use discriminator or having one collection where each document property is an array of document corresponding to each collection? Thansk for response
Juha Lindstedt
@pakastin
Mar 02 2018 18:54
I haven’t tried them (yet), maybe someone else can answer..