Add api to get users for initial app start

This commit is contained in:
2024-09-09 23:03:48 -05:00
parent 28f44c35c6
commit c8cb5d16d1
2 changed files with 35 additions and 0 deletions

View File

@@ -3,6 +3,20 @@ import { db } from '~/server/db';
import * as schema from '~/server/db/schema';
import { eq } from 'drizzle-orm';
export const getUsers = async () => {
try {
const result = await db.select({
id: schema.users.id,
name: schema.users.name,
message: schema.users.message,
}).from(schema.users);
return result;
} catch (error) {
console.error("Error fetching users", error);
throw new Error("Failed to fetch users");
}
};
export const getMessage = async (userId: number) => {
try {
let message = 1;