getPreviouslyMatchedUrls() { return new Promise((resolve, reject) => { this.db.find({type: 'matchedTorrents'}, (err, docs) => { if (err) { reject(err); } resolve(docs.reduce((matchedUrls, doc) => matchedUrls.concat(doc.urls), [])); }); }); }
initialUserGate(handlers) { this.db.find({}, (err, users) => { if (users && users.length > 0) { return handlers.handleSubsequentUser(); } return handlers.handleInitialUser(); }); }
getData(opts, callback) { const minTimestamp = Date.now() - this.opts.maxTime; this.db .find({ts: {$gte: minTimestamp}}) .sort({ts: 1}) .exec((err, docs) => { if (err) { callback(null, err); return; } callback(docs); }); }
getNotifications(query, callback) { const sortedNotifications = this.db.find({}).sort({ts: -1}); const queryCallback = (err, docs) => { if (err) { callback(null, err); return; } callback({notifications: docs, count: this.count}); }; if (query.allNotifications) { sortedNotifications.exec(queryCallback); } else if (query.start != null) { sortedNotifications .skip(Number(query.start)) .limit(Number(query.limit) || DEFAULT_QUERY_LIMIT) .exec(queryCallback); } else { sortedNotifications.limit(Number(query.limit) || DEFAULT_QUERY_LIMIT).exec(queryCallback); } }
countNotifications() { this.db.find({}, (err, docs) => { if (err) { this.count = Object.assign({}, INITIAL_COUNT_VALUE); } else { docs.forEach(notification => { if (notification.read) { this.count.read++; } else { this.count.unread++; } this.count.total++; }); } this.emitUpdate(); }); }
init() { this.feeds = []; this.rules = {}; this.db.find({}, (err, docs) => { if (err) { return;
}); } else { this.db.find({ts: this.lastUpdate}, (err, docs) => { if (docs.length !== 0) { const doc = docs[0];
getAll(query, callback) { query = query || {}; this.db.find({}, (err, docs) => { if (err) { callback(null, err); return; } callback( docs.reduce((memo, item) => { const type = `${item.type}s`; if (memo[type] == null) { memo[type] = []; } memo[type].push(item); return memo; }, {}), ); }); }
queryItem(type, query, callback) { query = query || {}; this.db.find(Object.assign(query, {type}), (err, docs) => { if (err) { callback(null, err); return; } callback(docs); }); }
listUsers(callback) { this.db.find({}, (err, users) => { if (err) { return callback(null, err); } return callback(users); }); }
app.get('/links/', function (req, res) { // TODO: Sort by created date instead of ID. db.find({}).sort({ id: -1 }).exec(function (err, links) { if (err) { res.statusCode = 404; res.json(err); }; res.json(links); }); });
app.get("/:transactionId", function(req, res) { transactionsDB.find({ _id: req.params.transactionId }, function(err, doc) { if (doc) res.send(doc[0]); }); });
app.get( "/products", function ( req, res ) { inventoryDB.find( {}, function ( err, docs ) { res.send( docs ); } ); } );
db.find({}, (err, list) => { if (err) { j(err); return; } r(list); });
function getCustomers(){ customerDB.find( {}, function ( err, docs ) { customers = docs; manageCustomers(); }); }