'Trying to call function by using db.eval("functionName()") in mongoDB compass version 4.4 But getting error as TypeError: db.eval is not a function

db.system.js.insertOne({
  _id: 'getMachinewiseLogDat',
  value: function () {
    return db.Smx_22235_ShiftOEEDaily.aggregate([
      {
        $group: {
          _id: '$machineName',
          maxlogdate: { $max: '$logDate' },
        },
      },
    ]);
  },
});

db.eval('getMachinewiseLogDat()');

Here I am writing one function, and trying to call it by using db.eval function but it's showing me this typeError. Anyone can tell me how to call this function in mongoDB compass version 4.4

You can refer this image, here's a code and error Error



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source