mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-01-01 18:38:18 -05:00
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
"use server";
|
|
import 'server-only';
|
|
|
|
import {prisma} from "@/lib/server/prisma";
|
|
|
|
|
|
export async function checkUserTableExists(): Promise<boolean> {
|
|
try {
|
|
await prisma.user.findFirst();
|
|
return true;
|
|
} catch {
|
|
// If there's an error, the table likely doesn't exist
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export async function retrieveUser(id: string) {
|
|
const cacheStrategy = {swr: 60, ttl: 60, tags: ["profiles_id"]};
|
|
const user = await prisma.user.findUnique({
|
|
where: {id},
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
// email: true,
|
|
image: true,
|
|
createdAt: true,
|
|
profile: {
|
|
include: {
|
|
intellectualInterests: {include: {interest: true}},
|
|
causeAreas: {include: {causeArea: true}},
|
|
coreValues: {include: {value: true}},
|
|
books: {include: {value: true}},
|
|
desiredConnections: {include: {connection: true}},
|
|
promptAnswers: true,
|
|
},
|
|
},
|
|
},
|
|
// cacheStrategy: cacheStrategy, TODO
|
|
});
|
|
|
|
// console.log("Fetched user profile:", user);
|
|
return user;
|
|
}
|