From f5934e19d2a55bb4d4f9cf12281a0dd8766365de Mon Sep 17 00:00:00 2001 From: Emily J Date: Sat, 17 Oct 2020 12:16:27 +1100 Subject: [PATCH] postgres --- bot/util/database.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/bot/util/database.js b/bot/util/database.js index e69de29..fd10d1f 100644 --- a/bot/util/database.js +++ b/bot/util/database.js @@ -0,0 +1,40 @@ +const { Pool } = require('pg'); + +const credentials = require('../../config.json').pgCredentials; + +class Database { + constructor(client) { + this.client = client; + this.pool = new Pool({ + user: credentials.user, + host: credentials.host, + database: credentials.database, + password: credentials.password, + port: credentials.port + }); + + this.pool.on('connect', () => { + this.client.logger.info('Connected to Postgres database.') + }) + }; + + async getGuild (id) { + return await this.pool.query('SELECT * FROM guilds WHERE guild_id = $1;', [id]); + }; + + async getGuildField (id, field) { + let res = await this.pool.query('SELECT $1 FROM guilds WHERE guild_id = $2;', [field, id]); + }; + + async getMember (guildID, userID) { + + }; + + async getUser (id) { + + }; + + +}; + +module.exports = Database; \ No newline at end of file