Use $ifNull instead of $cond in your $project:
{ $project: {MyKey: {$ifNull: ['$A', '$B'] }}}
If A exists and is not null its value will be used; otherwise the value of B is used.
Use $ifNull instead of $cond in your $project:
{ $project: {MyKey: {$ifNull: ['$A', '$B'] }}}
If A exists and is not null its value will be used; otherwise the value of B is used.