mongoose findone passing the id of the request to the callback using q model mongoose findone passing the id of the request to the callback using q model mongoose mongoose

mongoose findone passing the id of the request to the callback using q model


May be you can store your data in variable and access it in callback?

var findUser = function (userToFind) {    return q.when(administratorModel            .findOne({'username': userToFind})            .exec()            .then(function (username) {                if (!username) {                    throw new Error('Not found ' + userToFind);                }            }));}