-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
26 lines (25 loc) · 842 Bytes
/
db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const mongoose = require("mongoose");
const url =
"mongodb+srv://KMITKanteen:[email protected]/kanteen?retryWrites=true&w=majority";
mongoose.set('strictQuery', false);
const mongo = async () => {
await mongoose.connect(url, async (err, req) => {
if (err) {
console.log(err);
} else {
console.log("connected");
let food_data = await mongoose.connection.db.collection("food");
food_data.find({}).toArray(async (err, data) => {
let cat_data = await mongoose.connection.db.collection("foodCats");
cat_data.find({}).toArray((err, catsData) => {
if (!err) {
global.foods = data;
global.catData = catsData;
// console.log(data);
}
});
});
}
});
};
module.exports = mongo;