Minor fix for DB (working)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
create table promotions (
|
create table promotions (
|
||||||
id integer primary key autoincrement,
|
id integer primary key autoincrement,
|
||||||
|
name text,
|
||||||
endyear integer,
|
endyear integer,
|
||||||
current integer
|
current integer
|
||||||
);
|
);
|
||||||
@@ -9,6 +10,6 @@ create table students (
|
|||||||
firstName text,
|
firstName text,
|
||||||
lastName text,
|
lastName text,
|
||||||
mail text,
|
mail text,
|
||||||
promo integer,
|
promotionId integer,
|
||||||
foreign key(promo) references promo(id)
|
foreign key(promotionId) references promotions(id)
|
||||||
);
|
);
|
||||||
@@ -9,7 +9,7 @@ interface Student {
|
|||||||
id: number;
|
id: number;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
email: string;
|
mail: string;
|
||||||
promotionId: number;
|
promotionId: number;
|
||||||
promotionName: string;
|
promotionName: string;
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ export default function ConsultStudents() {
|
|||||||
{error && <p className="error">{error}</p>}
|
{error && <p className="error">{error}</p>}
|
||||||
{data?.promotions.map((promo) => (
|
{data?.promotions.map((promo) => (
|
||||||
<div key={promo.id}>
|
<div key={promo.id}>
|
||||||
<h3>Promotion: {promo.name}</h3>
|
<h3>Promotion: {promo.id}</h3>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -61,7 +61,7 @@ export default function ConsultStudents() {
|
|||||||
<td>{student.id}</td>
|
<td>{student.id}</td>
|
||||||
<td>{student.firstName}</td>
|
<td>{student.firstName}</td>
|
||||||
<td>{student.lastName}</td>
|
<td>{student.lastName}</td>
|
||||||
<td>{student.email}</td>
|
<td>{student.mail}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const handler: Handlers = {
|
|||||||
|
|
||||||
const students = connection.database
|
const students = connection.database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select userId, firstName, lastName, mail, promo from students`,
|
`select userId, firstName, lastName, mail, promotionId from students`,
|
||||||
)
|
)
|
||||||
.all();
|
.all();
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ export const handler: Handlers = {
|
|||||||
console.log(`Promotion ID for "${promoName}":`, promoId);
|
console.log(`Promotion ID for "${promoName}":`, promoId);
|
||||||
|
|
||||||
const insertQuery = connection.database.prepare(
|
const insertQuery = connection.database.prepare(
|
||||||
"INSERT INTO students (firstName, lastName, email, promotionId) VALUES (?, ?, ?, ?)",
|
"INSERT INTO students (firstName, lastName, mail, promotionId) VALUES (?, ?, ?, ?)",
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const student of data) {
|
for (const student of data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user