最好的方法是使用Promises。像这样做。
function getUsers () { return new Promise(function(resolve, reject) { database.collection("customers").find().toArray( function(err, docs) { if (err) { // Reject the Promise with an error return reject(err) } // Resolve (or fulfill) the promise with data return resolve(docs) }) })}


