2020-06-15 18:23:51 +02:00
|
|
|
import { ipcMain } from 'electron';
|
|
|
|
import InformationSchema from '../models/InformationSchema';
|
2020-07-24 13:26:56 +02:00
|
|
|
import Tables from '../models/Tables';
|
2020-06-15 18:23:51 +02:00
|
|
|
|
2020-06-16 18:01:22 +02:00
|
|
|
// TODO: remap objects based on client
|
|
|
|
|
2020-06-15 18:23:51 +02:00
|
|
|
export default (connections) => {
|
|
|
|
ipcMain.handle('getTableColumns', async (event, { uid, schema, table }) => {
|
|
|
|
try {
|
2020-07-05 16:06:56 +02:00
|
|
|
const result = await InformationSchema.getTableColumns(connections[uid], schema, table);// TODO: uniform column properties
|
2020-06-15 18:23:51 +02:00
|
|
|
return { status: 'success', response: result };
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return { status: 'error', response: err.toString() };
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ipcMain.handle('getTableData', async (event, { uid, schema, table }) => {
|
|
|
|
try {
|
2020-07-24 13:26:56 +02:00
|
|
|
const result = await Tables.getTableData(connections[uid], schema, table);
|
2020-06-15 18:23:51 +02:00
|
|
|
return { status: 'success', response: result };
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return { status: 'error', response: err.toString() };
|
2020-08-14 18:07:29 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ipcMain.handle('get-key-usage', async (event, { uid, schema, table }) => {
|
|
|
|
try {
|
|
|
|
const result = await InformationSchema.getKeyUsage(connections[uid], schema, table);
|
|
|
|
return { status: 'success', response: result };
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return { status: 'error', response: err.toString() };
|
2020-06-15 18:23:51 +02:00
|
|
|
}
|
|
|
|
});
|
2020-06-27 15:14:08 +02:00
|
|
|
|
|
|
|
ipcMain.handle('updateTableCell', async (event, params) => {
|
|
|
|
try {
|
2020-07-24 13:26:56 +02:00
|
|
|
const result = await Tables.updateTableCell(connections[params.uid], params);
|
2020-06-27 15:14:08 +02:00
|
|
|
return { status: 'success', response: result };
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return { status: 'error', response: err.toString() };
|
|
|
|
}
|
|
|
|
});
|
2020-07-23 19:10:14 +02:00
|
|
|
|
|
|
|
ipcMain.handle('deleteTableRows', async (event, params) => {
|
|
|
|
try {
|
2020-07-24 13:26:56 +02:00
|
|
|
const result = await Tables.deleteTableRows(connections[params.uid], params);
|
2020-07-23 19:10:14 +02:00
|
|
|
return { status: 'success', response: result };
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return { status: 'error', response: err.toString() };
|
|
|
|
}
|
|
|
|
});
|
2020-08-12 18:12:30 +02:00
|
|
|
|
|
|
|
ipcMain.handle('insertTableRows', async (event, params) => {
|
|
|
|
try {
|
|
|
|
await Tables.insertTableRows(connections[params.uid], params);
|
|
|
|
return { status: 'success' };
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return { status: 'error', response: err.toString() };
|
|
|
|
}
|
|
|
|
});
|
2020-06-15 18:23:51 +02:00
|
|
|
};
|