diff --git a/db/profile.ts b/db/profile.ts index 2f28d46..4571ccb 100644 --- a/db/profile.ts +++ b/db/profile.ts @@ -2,16 +2,26 @@ import { supabase } from "@/lib/supabase/browser-client" import { TablesInsert, TablesUpdate } from "@/supabase/types" export const getProfileByUserId = async (userId: string) => { + console.log(`..................Fetching profile for userId: ${userId}`) // 日志:打印查询的用户 ID const { data: profile, error } = await supabase .from("profiles") .select("*") .eq("user_id", userId) .single() + + if (error) { + console.error(`Error fetching profile: ${error.message}`) // 错误日志 + throw new Error(error.message) + } + + if (!profile) { + console.log(`No profile found for userId: ${userId}`) // 日志:如果没有找到 profile throw new Error(error.message) } + console.log(`Found profile for userId: ${userId}`, profile) // 日志:打印找到的 profile return profile }