-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabase.js
29 lines (22 loc) · 963 Bytes
/
Database.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
27
28
29
const { MongoClient } = require("mongodb");
module.exports = class Database {
async init() {
this.client = await MongoClient.connect("mongodb+srv://api:[email protected]/steeker?retryWrites=true&w=majority", {useNewUrlParser: true, useUnifiedTopology: true});
this.db = this.client.db("steeker");
}
async getUserPacks(userID) {
const collection = this.db.collection("packs");
const data = await collection.find({ creator: userID }).toArray();
return data
}
async getPack(packID, userID) {
const collection = this.db.collection("packs");
const data = await collection.findOne({ creator: userID, pack_id: packID});
return data;
}
// async isUserWhitelisted(userID) {
// const collection = self.db.collection("whitelisted");
// const data = await collection.findOne({ user: userID })
// return !!data
// }
}