lookupUser(credentials, callback) { this.db.findOne({username: credentials.username}, (err, user) => { if (err) { return callback(err); } return callback(null, user); }); }
comparePassword(credentials, callback) { this.db.findOne({username: credentials.username}).exec((err, user) => { if (err) { return callback(null, err); } // Username not found. if (user == null) { return callback(null, user); } argon2 .verify(user.password, credentials.password) .then(argon2Match => { if (argon2Match) { return callback(argon2Match, user.isAdmin); } callback(null, argon2Match, false); }) .catch(error => callback(null, error)); }); }
removeUser(username, callback) { this.db.findOne({username}).exec((findError, user) => { if (findError) { return callback(null, findError); } // Username not found. if (user == null) { return callback(null, user); } this.db.remove({username}, {}, removeError => { if (removeError) { return callback(null, removeError); } fs.removeSync(path.join(config.dbPath, user._id)); return callback({username}); }); }); }
app.post( "/product/sku", function ( req, res ) { var request = req.body; inventoryDB.findOne( { _id: parseInt(request.skuCode) }, function ( err, product ) { res.send( product ); } ); } );
app.get( "/user/:userId", function ( req, res ) { if ( !req.params.userId ) { res.status( 500 ).send( "ID field is required." ); } else{ usersDB.findOne( { _id: parseInt(req.params.userId) }, function ( err, docs ) { res.send( docs ); } ); } } );
Watchlist.findOne({ steamid64: steamID64.toString() }, (err, profile) => { if (err) { console.error(`[${new Date().toUTCString()}] NEDB (searchWatchlist) > ${err}`); reject(); } if (profile) { resolve(); } reject(); });
_getLatest(callback = (x, y) => y || x) { return Queue.findOne({}) .sort({created: -1}) .limit(1).exec(callback) }
routeId.get((req, res) => { db.findOne({_id:req.params.id}).exec((err, user) => { if (err) { app.utils.error.send(err, req, res); } else { res.status(200).json(user); } }); })
// Get the endpoint URL to update trackers function getTrackerEP() { return new Promise((resolve, reject) => { config.findOne({type: 'trackers'}, function (err, trck) { if (!err && trck) { resolve(trck.url); } else { console.log(err); reject(); } }) }); }
_select(path, callback) { db.findOne({ path: path }, function (err, doc) { callback(doc); }); }
app.get( "/customer/:customerId", function ( req, res ) { if ( !req.params.customerId ) { res.status( 500 ).send( "ID field is required." ); } else { customerDB.findOne( { _id: req.params.customerId }, function ( err, customer ) { res.send( customer ); } ); } } );
function get (id, cb) { db.findOne({ _id: id }, cb) }
// Get trackers list from DB function getTrackers() { return new Promise((resolve, reject) => { config.findOne({type: 'trackers'}, function (err, trck) { if (!err && trck) { resolve(trck.trackers); } else { console.log(err); reject(); } }) }); }
app.get( "/product/:productId", function ( req, res ) { if ( !req.params.productId ) { res.status( 500 ).send( "ID field is required." ); } else { inventoryDB.findOne( { _id: parseInt(req.params.productId) }, function ( err, product ) { res.send( product ); } ); } } );
_getLatest(callback = (x, y) => y || x) { return Queue.findOne({}) .sort({created: -1}) .limit(1).exec(callback) }