如果在congo中进行cond [英] If else if cond in mongodb aggregation
本文介绍了如果在congo中进行cond的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这已经被问过了,但是我似乎找不到答案,如何在总计$ project中添加条件
I know this has been asked before but I can't seem to find the answer, how to add condition in aggregate $project
Schedul.aggregate([
{ $match: { flag: 1 } },
{
$project: {
"name": "$name",
"day_of_week": ("$day_of_week" === 0) ? 'Sunday' : ("$day_of_week" === 1) ? 'Monday' : ("$day_of_week" === 2) ? 'Tuesday' : ("$day_of_week" === 3) ? 'Wednesday' : ("$day_of_week" === 4) ? 'Thursday' : ("$day_of_week" === 5) ? 'Friday' : 'Saturday',
}
},
])
推荐答案
您可以使用
这篇关于如果在congo中进行cond的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文