Hi,
My problem: a single Collection.update() is causing 5-7 queries to MongoDB
I discovered this by chance, because I have turned on System Profiling locally:
$ meteor mongo
MongoDB shell version: 3.2.15
connecting to: 127.0.0.1:3001/meteormeteor:PRIMARY> db.setProfilingLevel(2)
{ “was” : 0, “slowms” : 100, “ok” : 1 }
My code looks something like this:
Collection.update(
{
_id: documentId,
},
{
$addToSet: {
likedBy: this.userId,
},
},
);
This results in 7 queries: 1 updateObj query, and 7 read queries.
If I use Collection.direct.update, then 2 of the read queries disappear.
I have a couple of theories for as to who’s generating the reads, but would be nice to have tracking tool.
Is there anything in Meteor that would allow me to pinpoint exactly where any kind of query is coming from?