MongoError: The $subtract accumulator is a unary operator : <p>I can't seem to find any solutions for this problem. I just can't figure out what is wrong.</p>

<p>I already tried this <a href="https://stackoverflow.com/questions/46722968/mongo-subtract-in-group-aggregation">Mongo subtract in group aggregation</a> but no hope. The post also failed to explain further.</p>

<p>Here is my code: </p>

<pre><code> var aggregateOptions;
  aggregateOptions = [{
    $match: {

    }
  },{
    $group: {
      _id: "$customerID",
      totalAmount: { $sum: "$amount" },
      totalpaidAmount: { $sum: "$paidAmount" },
      totalAmountDue: { $subtract: ["$totalAmount", "totalpaidAmount"] }
    }
  }];

  Sale.sales.get(Sale.Schema, aggregateOptions, (err, saleRecord) =&gt; {
    if (err) throw err;
    console.log(saleRecord);

    res.json({
      pageTitle: "Customer List",
      currentUser: req.user,
      saleRecord: saleRecord,
    });
  });
</code></pre>

<p>it prompts MongoError: The $subtract accumulator is a unary operator everytime I query it.</p>
