20 lines
491 B
TypeScript
20 lines
491 B
TypeScript
import { eq } from "drizzle-orm";
|
|
import db from "../../db";
|
|
import { clientsTable } from "../../db/schema";
|
|
import { status } from "elysia";
|
|
|
|
async function getByPhone(phone: string) {
|
|
try {
|
|
return (
|
|
(await db.query.clientsTable.findFirst({
|
|
where: eq(clientsTable.phone, phone),
|
|
})) || status(404, "Not Found")
|
|
);
|
|
} catch (error) {
|
|
console.log((error as Error).message);
|
|
return status(500, "Internal Server Error");
|
|
}
|
|
}
|
|
|
|
export default getByPhone;
|