-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
111be49
commit ee655d8
Showing
2 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-FileCopyrightText: 2024 Marcellino Palerme <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// this file is used to update the expected concentration of the daughters | ||
// of a calibration curve | ||
|
||
import pg from "pg"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
const body = await readBody(event); | ||
const client = new pg.Client(); | ||
return client.connect() | ||
.then(() => { | ||
const lQueryPromises = []; | ||
// for each daughter solution | ||
for(const idFile in body.daughters){ | ||
// for each metabolite of the daughter solution | ||
for(const daughter of body.daughters[idFile]){ | ||
// update expected concentration | ||
lQueryPromises.push(client.query(` | ||
UPDATE daughter | ||
SET expected = ${daughter.expectedArea} | ||
WHERE id_file = ${idFile} | ||
AND id_mol = '${daughter.nameMeta}' | ||
AND id_calib_curves = ${body.idCalibCurve}` | ||
)); | ||
} | ||
} | ||
return Promise.all(lQueryPromises); | ||
}) | ||
.then(() => { | ||
// update the calibration curve name | ||
return client.query(` | ||
UPDATE calib_curves | ||
SET name = '${body.nameCalibCurve}' | ||
WHERE id = ${body.idCalibCurve}` | ||
); | ||
}) | ||
.catch((err: Error) => { | ||
throw err; | ||
}) | ||
.finally(() => client.end()); | ||
}); |