统计条件查询

if amount < 0, then 0 - amount  else 

{ $project: {
  amount: {
    $cond: [
      { $lt: ['$amount', 0] },
      { $subtract: [0, '$amount'] }, 
      '$amount'
    ]
}}}

猜你喜欢

转载自wang-peng1.iteye.com/blog/1979503