I tried to run queries from browsers console and got following results:
Results.find({ results: { $elemMatch: { errorId: "uX6byeiuGjRNXTj6s"} } }).fetch()
[Object { _id="9FK5k755ueAYdfip3", results=[435], createdAt=Date}]
Results.find({ results: { $elemMatch: { "results.errorId": "uX6byeiuGjRNXTj6s"} } }).fetch()
[]
Results.aggregate([{$unwind: '$results'},{$match: {'results.errorId': 'uX6byeiuGjRNXTj6s'}}]).fetch()
TypeError: Results.aggregate is not a function
...gregate([{$unwind: '$results'},{$match: {'results.errorId': 'uX6byeiuGjRNXTj6s'}...
First query returned all ids instead of just "uX6byeiuGjRNXTj6s". Other two queries didnt work.
Then I tried to run them directly (meteor mongo) from db and got below results.
db.results.find({ results: { $elemMatch: { errorId: "uX6byeiuGjRNXTj6s"} } })
- returned ALL ids
db.results.find({ results: { $elemMatch: { "results.errorId": "uX6byeiuGjRNXTj6s"} } })
- returned empty
meteor:PRIMARY> db.results.aggregate([{$unwind: '$results'},{$match: {'results.errorId': 'uX6byeiuGjRNXTj6s'}}])
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 13:01:29 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 13:01:29" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 13:01:29 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 13:01:29" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 13:22:42 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 13:22:42" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 13:22:43 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 13:22:43" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 13:49:33 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 13:49:33" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 13:49:34 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 13:49:34" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 14:02:22 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 14:02:22" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 14:02:22 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 14:02:22" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 14:30:41 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 14:30:41" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 14:30:41 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 14:30:41" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 15:46:41 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 15:46:41" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/09/15 15:46:42 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/09/15 15:46:42" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/10/15 15:26:24 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/10/15 15:26:24" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/10/15 15:26:24 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/10/15 15:26:24" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/10/15 15:40:47 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/10/15 15:40:47" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/10/15 15:40:48 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/10/15 15:40:48" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/10/15 15:47:49 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/10/15 15:47:49" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/10/15 15:47:49 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/10/15 15:47:49" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/10/15 16:08:38 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup\\clb.lb': The lockbox file was not found. ", "time" : "02/10/15 16:08:38" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
{ "_id" : "9FK5k755ueAYdfip3", "results" : { "errorId" : "uX6byeiuGjRNXTj6s", "error" : "02/10/15 16:08:38 backup.swatycomet.lan nsrd Error encountered while re-signing lockbox 'D:\\EMC\\Networker\\nsr\\lockbox\\backup.comet.si\\clb.lb': The lockbox file was not found. ", "time" : "02/10/15 16:08:38" }, "createdAt" : ISODate("2016-03-12T18:58:46.967Z") }
Type "it" for more
So here third query returned what I need. Then I tried to run that query in my meteor code:
console.log(Results.aggregate([{$unwind: '$results'},{$match: {'results.errorId': 'uX6byeiuGjRNXTj6s'}}]));
but get below error instead of results.
Exception in template helper: .errors@http://localhost:3000/app/client/templates/results/results.js?951539bd4f24742e5d7a64530c2463bfe41fde91:33:21
bindDataContext/<@http://localhost:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:2986:14
What I am doing wrong?