postgres
This commit is contained in:
parent
dad9231a5f
commit
f5934e19d2
1 changed files with 40 additions and 0 deletions
|
@ -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;
|
Loading…
Reference in a new issue