-
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
fcc06e5
commit ba21455
Showing
4 changed files
with
57 additions
and
9 deletions.
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 |
---|---|---|
|
@@ -149,6 +149,13 @@ FROM series, ratio | |
WHERE series.id = ratio.id_series | ||
GROUP BY series.id; | ||
|
||
CREATE TABLE proj_series | ||
( | ||
id_project SERIAL REFERENCES project (id) ON DELETE CASCADE, | ||
id_series SERIAL REFERENCES series (id) ON DELETE CASCADE, | ||
PRIMARY KEY (id_project, id_series) | ||
); | ||
|
||
INSERT INTO users (name, email, hash, team) | ||
VALUES | ||
('root_ep2m2', '[email protected]', | ||
|
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,30 @@ | ||
// SPDX-FileCopyrightText: 2024 Marcellino Palerme <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import pg from "pg"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
const body = await readBody(event); | ||
const client = new pg.Client(); | ||
return client.connect() | ||
.then(() => { | ||
console.log(body); | ||
|
||
const lPromises = []; | ||
for(const idSerie of body.series){ | ||
lPromises.push( | ||
client.query(` | ||
INSERT INTO proj_series(id_project, id_series) | ||
VALUES ('${body.id_project}', '${idSerie}')` | ||
) | ||
); | ||
} | ||
return Promise.allSettled(lPromises); | ||
}) | ||
.catch((err: Error) => { | ||
throw err; | ||
}) | ||
.finally(() => client.end()); | ||
|
||
}); |
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