2018-03-07 09:12:44 +01:00
|
|
|
/**
|
|
|
|
* BetterDiscord Database Module
|
|
|
|
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
|
|
|
|
* All rights reserved.
|
|
|
|
* https://betterdiscord.net
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
2018-03-21 21:52:42 +01:00
|
|
|
import { ClientIPC } from 'common';
|
2018-03-07 09:12:44 +01:00
|
|
|
|
|
|
|
export default class {
|
|
|
|
|
2018-03-07 09:28:14 +01:00
|
|
|
static async init() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-21 00:24:31 +01:00
|
|
|
/**
|
|
|
|
* Inserts or updates data in the database.
|
|
|
|
* @param {Object} args The record to find
|
|
|
|
* @param {Object} data The new record
|
|
|
|
* @return {Promise}
|
|
|
|
*/
|
2018-03-07 09:12:44 +01:00
|
|
|
static async insertOrUpdate(args, data) {
|
|
|
|
try {
|
|
|
|
return ClientIPC.send('bd-dba', { action: 'update', args, data });
|
|
|
|
} catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-21 00:24:31 +01:00
|
|
|
/**
|
|
|
|
* Finds data in the database.
|
|
|
|
* @param {Object} args The record to find
|
|
|
|
* @return {Promise}
|
|
|
|
*/
|
2018-03-07 09:12:44 +01:00
|
|
|
static async find(args) {
|
|
|
|
try {
|
|
|
|
return ClientIPC.send('bd-dba', { action: 'find', args });
|
|
|
|
} catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
}
|
2018-03-21 21:52:42 +01:00
|
|
|
|
2018-03-07 09:12:44 +01:00
|
|
|
}
|