MongoClient.connect('mongodb://localhost:27017/admin', {useNewUrlParser: true}, (err, mconn) => { if(err) { console.error(err) process.exit(1) } torrentdb = mconn.db('torrent') torrentdb.collection('log').createIndex({date: 1, reqs: -1}) torrentdb.collection('log').createIndex({hash: 1}) torrentdb.collection('hash').createIndex({hash: 1}, {unique: 1}) torrentdb.collection('hash').find().sort({_id: -1}).limit(1).next((err, r) => { nextTorrentId = (r && r._id || 0) + 1 console.log('Next torrent _id is', nextTorrentId, 'tableCaption', process.env.TABLE_CAPTION) }) })
const stream = torrentdb.collection('hash').find().stream() const d = [] stream.on('error', (err) => {
const stream = torrentdb.collection('log').find({date: process.env.DATE}).stream() const d = [] let ii = 0
async getSignups(param,options){ if (!param.season){ param.season = "season 15"; } return await this.signups.find(param,options).toArray(); }
runQueryOrThrowAuthError(async () => { const config = Config.get(); let result = await mongoClient .db() .collection(config.mongo.collections.refreshTokens) .find({}) .count(); return Number(result); })
mongoose.connection.db.collection('experiences', function (err, collection) { if (err) throw err; collection.find({}).toArray(function (err, experiences) { res.send(experiences) }); });
// // Data access methods for event documents // queryEvents(query) { return this.db.collection(this.EVENT_COLLECTION).find(query).toArray(); }
findAll(col, search, callback) { if (search._id) search._id = new mongodb.ObjectId(search._id); this.reconnect(()=> { this.DB.collection(col).find(search).toArray((err, docs) => { if (err) { console.log(err); } callback(docs); }); }); }
async function assembleUserState(user) { const db = await connectDB(); const tasks = await db.collection('tasks').find({ owner: user.id }).toArray(); const groups = await db.collection('groups').find({ owner: user.id }).toArray(); return { tasks, groups, session: { authenticated: 'AUTHENTICATED', id: user.id }, }; }
app.get("/data", async (req, res) => { const mongo = await connectMongo(); const x = await mongo .db("game-sales-demo") .collection("games") .find({}) .toArray(); res.send(x); });
client.connect(err => { const collection = client.db("noahdb").collection("questions"); var query = { address: "Highway 37" }; collection.find(query).toArray(function(err, result) { if (err) throw err; console.log(result); }); client.close(); });
db.collection(tableName).find().sort({'id': 1}).toArray(function(err, result) { if(result == [] || result == ''){ res.send('Sorry table not found in database'); } else{ output.contents = result; res.send(output); } });
async function find(collectionname,json) { const client = new MongoClient(url, {useUnifiedTopology: true}); await client.connect(); const col = client.db("spider").collection(collectionname); const result = await col.find(json).toArray(); client.close(); return result; }
// // Data access methods for feedback documents // listFeedbackForEventTopic(eventid, topicid) { return this.db.collection(this.FEEDBACK_COLLECTION).find({$and: [{event: eventid}, {topic: topicid}]}).toArray(); }
mongoose.connection.db.collection('restaurants', function (err, collection) { if (err) throw err; collection.find({}).toArray(function (err, restaurants) { res.send(restaurants) }); });