mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
commiting missing utils file
This commit is contained in:
parent
b5ab39cb09
commit
d3dc668dd0
1 changed files with 21 additions and 0 deletions
21
src/app/portfolio/[slug]/utils.ts
Normal file
21
src/app/portfolio/[slug]/utils.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { eq } from "drizzle-orm";
|
||||
import { db } from "@/app/db/db";
|
||||
import { portfolio } from "@/app/db/schema/portfolio";
|
||||
import type { Portfolio } from "@/app/db/schema/portfolio";
|
||||
|
||||
export async function getPortfolio(portfolioId: number): Promise<Portfolio> {
|
||||
const data = await db
|
||||
.select()
|
||||
.from(portfolio)
|
||||
.where(eq(portfolio.id, portfolioId));
|
||||
|
||||
if (data.length === 0) {
|
||||
throw new Error("Portfolio not found");
|
||||
}
|
||||
|
||||
if (data.length > 1) {
|
||||
throw new Error("More than one portfolio found");
|
||||
}
|
||||
|
||||
return data[0];
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue