const { Provider } = require('../interfaces/'); const { MongoClient } = require('mongodb'); class MongoDBProvider extends Provider { constructor(client, config) { super(client, { name: 'mongodb', config }); } async initialize() { try { this.connection = await MongoClient.connect(this.config.host+this.config.database, { useUnifiedTopology: true }); this.db = await this.connection.db(this.config.database); return this._initialized = true; //eslint-disable-line no-return-assign } catch(err) { this._error(err); return false; } } get guilds() { return this.tables.guilds; } get permissions() { return this.tables.permissions; } get infractions() { return this.tables.infractions; } get messages() { return this.tables.messages; } get attachments() { return this.tables.attachments; } get users() { return this.tables.users; } get role_cache() { return this.tables.role_cache; } } module.exports = MongoDBProvider;