вы можете использовать $concat
db.t55.aggregate([
{$addFields : {
id : {$concat : [{$cond :["$isPaid", "1","0"]}, ".", "$state", "." ,"$updatedAt"]}
}}
])
, используя $toString
, если не просто true / false
db.t55.aggregate([
{$addFields : {
id : {$concat : [{$toString :{$indexOfArray : [[false,true], "$isPaid"]}}, ".", "$state", "." ,"$updatedAt"]}
}}
])
output
{ "_id" : ObjectId("5c3e794b21526e3ff4bf4ca2"), "id" : "0.approved.2018-06-27", "state" : "approved", "isPaid" : false, "updatedAt" : "2018-06-27", "totalCount" : 1, "totalValue" : 658.4332 }
{ "_id" : ObjectId("5c3e794b21526e3ff4bf4ca3"), "id" : "0.canceled.2018-05-30", "state" : "canceled", "isPaid" : false, "updatedAt" : "2018-05-30", "totalCount" : 1, "totalValue" : 1735.7175 }