2020-06-15 18:23:51 +02:00
|
|
|
import { ipcMain } from 'electron';
|
|
|
|
import InformationSchema from '../models/InformationSchema';
|
|
|
|
import Generic from '../models/Generic';
|
|
|
|
|
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 {
|
|
|
|
const result = await InformationSchema.getTableColumns(connections[uid], schema, table);
|
|
|
|
return { status: 'success', response: result };
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return { status: 'error', response: err.toString() };
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ipcMain.handle('getTableData', async (event, { uid, schema, table }) => {
|
|
|
|
try {
|
|
|
|
const result = await Generic.getTableData(connections[uid], schema, table);
|
|
|
|
return { status: 'success', response: result };
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
return { status: 'error', response: err.toString() };
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|