Skip to content
Snippets Groups Projects
Commit 88a9123f authored by Ricardo's avatar Ricardo
Browse files

FIX import name adjust

parent 6b8bc767
No related branches found
No related tags found
No related merge requests found
import { type Request, type Response } from 'express';
import { implants } from '@/db/schema';
import { implantsTable } from '@/db/schema';
import { db } from "@/db";
import { eq } from 'drizzle-orm';
import { implantSchema } from '@/validators/implantsValidator';
......@@ -15,7 +15,7 @@ export default class implant{
}
static async getImplant (id: number){
const searched = await db.select().from(implants).where(eq(implants.id, id)).limit(1);
const searched = await db.select().from(implantsTable).where(eq(implantsTable.id, id)).limit(1);
return searched[0] || null;
}
......@@ -47,7 +47,7 @@ export default class implant{
return res.status(404).json({ error: "Not Found"});
}
const updates: Partial<typeof implants.$inferInsert> = {
const updates: Partial<typeof implantsTable.$inferInsert> = {
name: req.body.name || updated_implant.name,
price: req.body.price || updated_implant.price,
cyberCost: req.body.cyberCost || updated_implant.cyberCost,
......@@ -55,7 +55,7 @@ export default class implant{
};
try{
await db.update(implants).set(updates).where(eq(implants.id, id));
await db.update(implantsTable).set(updates).where(eq(implantsTable.id, id));
} catch (error) {
return res.status (500).json({ error: "Update User Error"})
}
......@@ -75,7 +75,7 @@ export default class implant{
}
try{
await db.delete(implants).where(eq(implants.id, id));
await db.delete(implantsTable).where(eq(implantsTable.id, id));
return res.status(200).json({ message: "Implant removed successfully"});
} catch (error) {
return res.status(500).json({ error: "Implant Removal Error"});
......@@ -92,7 +92,7 @@ export default class implant{
const { name, price, cyberCost, bodyPart } = implant_package.data;
try{
const brand_new = await db.insert(implants).values({
const brand_new = await db.insert(implantsTable).values({
name,
price,
cyberCost,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment