const getUserCollectionsCached = async (userId: string, authenticated: boolean) => {
'use cache: private';
cacheLife('hours');
cacheTag(`user-collections-${userId}`);
if (!authenticated) throw new UnauthorizedError("User not authorized");
console.log(`[DAL][Collection][CACHE CHECKKKKK] Fetching collections for user: ${userId}`);
const supabase = await createClient();
const { data, error } = await supabase
.from("collection")
.select("*")
.eq("owner_id", userId)
.is("deleted_at", null);
if (error) {
console.error(`[ERROR][DAL][Collection_getUserCollections] User: ${userId} |`, error);
throw new InfraError("Failed to retrieve collections");
}
return data;
};
const getUserCollectionsCached = async (userId: string, authenticated: boolean) => {
'use cache: private';
cacheLife('hours');
cacheTag(`user-collections-${userId}`);
if (!authenticated) throw new UnauthorizedError("User not authorized");
console.log(`[DAL][Collection][CACHE CHECKKKKK] Fetching collections for user: ${userId}`);
const supabase = await createClient();
const { data, error } = await supabase
.from("collection")
.select("*")
.eq("owner_id", userId)
.is("deleted_at", null);
if (error) {
console.error(`[ERROR][DAL][Collection_getUserCollections] User: ${userId} |`, error);
throw new InfraError("Failed to retrieve collections");
}
return data;
};