I need to add condition to find depends to variable value : if it is null don't add to condition if not null - add. I am new in mongodb and for example I gen get it from SQL
DECLARE Variable int = null
SELECT * FROM Table
WHERE field = isnull(Variable ,field)
In mongodb I try to do find
let Variable = "aa";
db.Table.find({
$or: [{field:Variable },{Variable : null }]
})
But its don't work as expected Please assist