Database

[{"uuid":1,"name":"adam","jobUuid":"default"},{"uuid":1,"jobUuid":"1","name":"adam"},{"uuid":2,"name":"eve","jobUuid":"default",},{"uuid":2,"jobUuid":"1","name":"eve"},{"uuid":3,"name":"john","jobUuid":"default"}]

Query

db.collection.aggregate([{"$match":{"jobUuid":{"$in":["1","default"]}}},{"$group":{"_id":"$uuid","name":{"$first":"$name"},"jobUuids":{"$addToSet":{"$cond":{"if":{"$ne":["$jobUuid","default"]},"then":"$jobUuid","else":"$$REMOVE"}}}}},{"$project":{"_id":0,"uuid":"$_id","name":1,"jobUuid":{"$ifNull":[{"$arrayElemAt":["$jobUuids",0]},"default"]}}}])

Result