antares/src/main/ipc-handlers/tables.js

48 lines
1.6 KiB
JavaScript
Raw Normal View History

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-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-06-15 18:23:51 +02:00
};