I have a function that sends a query to ipcMain and then waits for the SQL query to be ran. When the response comes back I loop over the returned data and display that on screen for the user to see.
For some reason whenever the data is return and I log it from the render process it is sorted alphabetically. I haven't been able to determine where/why this sorting is occurring.
It would seem to me based on console.logs that sometime between ipcMain sending the request and the render process receiving the data it is getting sorted.
Any insight would be apprciated.
I've logged in all the blatant places to see if I can diagnose where the ordering is coming from.
// function that gets the results
// This console.log is alphabetically sorted here
runQuery(config){
window.ipc.send('run-query', config);
return new Promise((resolve, reject) => {
window.ipc.on('run-query-reply', (event, result) => {
console.log(result)
resolve(result);
});
});
}
// calls handler - it is not sorted on this console.log
ipcMain.on('run-query', async (event, arg) => {
var results = await handlers.runQuery(event, arg, scope);
console.log(results)
event.sender.send('run-query-reply', results)
})
// handler function - it is not sorted on this console.log
async function runQuery (){
try {
var connection = await new scope.sql(arg.server.database, arg.server.username, arg.server.password, config);
return await connection.query(query).spread((results) => {
console.log(results)
return results;
})
} catch (error) {
return scope.errorHandler(error.message)
}
}
Sample Data:
// Data in ipcMain would like like:
{
"email": "test",
"contact-id":"1",
"first-name":"test",
"allow-email":test"
}
// Data from render window.ipc
{
"allow-email":"test",
"contact-id":"1",
"email": "test",
"first-name":"test"
}