blob: 5e2f0c96e8e121c2a8292c6b6f1055d34c18a880 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import supabase from './supabase';
interface UserConfiguration {
user_id: number;
configuration: any;
created_at: string;
updated_at: string;
}
export const getUserConfiguration = async (userId: number) => {
const { data, error } = await supabase
.from('user_configuration')
.select('*')
.eq('user_id', userId);
if (error || data.length === 0 || data[0].user_id !== userId) return null;
return data[0] as UserConfiguration;
};
export const setUserConfiguration = async (userId: number, configuration: UserConfiguration) => {
const { data, error } = await supabase
.from('user_configuration')
.upsert({ user_id: userId, configuration });
if (error || !data || (data as []).length === 0) return null;
return data[0] as UserConfiguration;
};
|