What is the best practice to handle valid conditional objects returned from Promises


#1

In my Promise function I might get valid but non user detected and the response would be

[ ]

But if there is a user then another the response would

[ { _id: 'RenC', count: 1 } ]

so how to do conditional .then for both valid but different conditions?

async function myFunction(name) {
    var promise = await new Promise(function (resolve, reject) {
        MyTasks.aggregate([
            {
                $match: {
                    "name": {$eq: name}
                }
            },
            {
                $group: {
                    _id: "$name", count: {$sum: 1}          
                }
            }
        ], (err, db) => {
            err ? reject(err) : resolve(db);
        });
    });
    return promise;
}

myFunction(name)
    .then(txt => console.log('Valid user', txt) <-  want to handle both valid cases???
    .catch(txt => console.error('Error reason is : ', txt)