Can someone help to achieve IF/ELSE in mongoDB? I use below code in SQL Server.
DECLARE @p =1
IF @p =1
PRINT @p
ELSE PRINT "NO"
I tried the below codes in MongoDB but could not succeed.
var p=1
{ $cond: { if: p=1, then: print(p), else: print("NO") } }
var p=1
{ $cond: { if: p=1, print(p), print("NO") } }