These are chat archives for Automattic/mongoose

29th
Aug 2017
wyemun
@wyemun
Aug 29 2017 08:50

Can somebody help me on this:
So i ran this on mongoshell and it works

db.printlogs.aggregate([
{
$group: {
                _id: {
                    printer: '$printer', // printer is ObjectId type
                    jobId: '$jobId' // jobId is String type
                }])

However, when i run it using mongoose:

PrinterLog.aggregate([
        {
          $group: {
            _id: {
              printer: '$printer',
              jobId: '$jobId',
            }])

The jobId is always null and hence the results does not account for the jobId. Is it something to do with because jobId is not an ObjectId ?

YasaaMoin
@Yasaa
Aug 29 2017 09:17
@wyemun Do give jobId a try as an ObjectId ? Maybe a little experimenting will reveal the answer