Posts

Showing posts with the label mongodb

Why is Collection.find() not working on my Meteor client?

I was sure to correctly create my collection, publish the data, subscribe to the right publication, and check that the data was actually appearing in the Mongo Shell. I even console.log()'d the data that was being published to ensure that the publication was working. Yet, the following line of code fails to return anything: const maybeMeet = Meets.find({meetId: maybeId}).fetch(); This could be found below and in Line 39 of /client/imports/routes/routes.js in the linked repo. At one point, I even tried to create a new Meteor method 'meets.query' that would just publish all the data I need, (insecurely) averting the need for a publications and subscriptions (it's now commented out on Line 59 of /client/imports/api/meets.js ). That too did not work. In general, it seems as if the client can't receive any data from the server, but going from the client to the server seems to work (I could insert things into my Meets collection). Here is the source of the problem (part...

Mongo Aggregation to Calculate Unique IDs in Returned Docs is Slow

In addition to returning a filtered set of documents to the end user via a Mongo view, I also have a couple functions running to generate running totals. For some reason though, while my find() operation is really fast (225ms), this additional aggregation I'm running takes over 6 seconds to perform -- which slows down the whole endpoint, because this data is passed on in what I'm returning. I'm trying to understand why this aggregation would be so slow? This aggregation matches to the filters passed in by the end-user, and then calculates the number of unique customer ids that appear in the returned documents. This is what it looks like: Why would this take 6 seconds to run? Any ideas? Any tips on how I can speed it up? Well, it'll definitely take some time, if there's a lot of distinct users (or a lot users in general). If you want to check, why it's taking so much time, try the explain argument. On the other hand, distinct might be a better choice here: ...