-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-supabase-data.js
More file actions
158 lines (134 loc) · 5.33 KB
/
Copy pathcheck-supabase-data.js
File metadata and controls
158 lines (134 loc) · 5.33 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<<<<<<< HEAD
const { createClient } = require('@supabase/supabase-js');
require('dotenv').config();
// Get Supabase credentials from environment variables
const supabaseUrl = process.env.SUPABASE_URL;
const supabaseKey = process.env.SUPABASE_KEY;
console.log('Checking Supabase data...');
// Validate credentials
if (!supabaseUrl || !supabaseKey) {
console.error('❌ Error: Supabase URL and Key are required in environment variables');
process.exit(1);
}
// Create Supabase client
const supabase = createClient(supabaseUrl, supabaseKey);
// Function to check if data is being saved
async function checkSupabaseData() {
try {
console.log('Connecting to Supabase...');
// Check if the users table exists and has data
const { data, error, count } = await supabase
.from('users')
.select('*', { count: 'exact' })
.order('created_at', { ascending: false })
.limit(5);
if (error) {
if (error.message.includes('relation "users" does not exist')) {
console.log('❌ Users table does not exist yet');
console.log('Please create the table using the SQL script provided earlier');
return;
} else {
console.error('❌ Error querying users table:', error.message);
return;
}
}
console.log(`✅ Successfully connected to Supabase!`);
console.log(`📊 Found ${count} records in the users table`);
if (data && data.length > 0) {
console.log('\n📋 Latest 5 records:');
data.forEach((record, index) => {
console.log(`\n--- Record ${index + 1} ---`);
console.log(`ID: ${record.id}`);
console.log(`Name: ${record.first_name} ${record.last_name}`);
console.log(`Birth Date: ${record.birth_date}`);
console.log(`Birth Time: ${record.birth_time}`);
console.log(`Birth Place: ${record.birth_place}`);
console.log(`Created At: ${record.created_at}`);
if (record.face_image_path) {
console.log(`Face Image: ${record.face_image_path}`);
}
if (record.hand_image_path) {
console.log(`Hand Image: ${record.hand_image_path}`);
}
if (record.analysis_result) {
console.log('Analysis Result: Data exists (not showing full content for brevity)');
}
});
} else {
console.log('\n📝 No records found in the users table yet');
console.log('This is normal if you haven\'t submitted any forms yet');
}
console.log('\n✅ Supabase integration is working correctly!');
} catch (error) {
console.error('❌ Error:', error.message);
process.exit(1);
}
}
=======
const { createClient } = require('@supabase/supabase-js');
require('dotenv').config();
// Get Supabase credentials from environment variables
const supabaseUrl = process.env.SUPABASE_URL;
const supabaseKey = process.env.SUPABASE_KEY;
console.log('Checking Supabase data...');
// Validate credentials
if (!supabaseUrl || !supabaseKey) {
console.error('❌ Error: Supabase URL and Key are required in environment variables');
process.exit(1);
}
// Create Supabase client
const supabase = createClient(supabaseUrl, supabaseKey);
// Function to check if data is being saved
async function checkSupabaseData() {
try {
console.log('Connecting to Supabase...');
// Check if the users table exists and has data
const { data, error, count } = await supabase
.from('users')
.select('*', { count: 'exact' })
.order('created_at', { ascending: false })
.limit(5);
if (error) {
if (error.message.includes('relation "users" does not exist')) {
console.log('❌ Users table does not exist yet');
console.log('Please create the table using the SQL script provided earlier');
return;
} else {
console.error('❌ Error querying users table:', error.message);
return;
}
}
console.log(`✅ Successfully connected to Supabase!`);
console.log(`📊 Found ${count} records in the users table`);
if (data && data.length > 0) {
console.log('\n📋 Latest 5 records:');
data.forEach((record, index) => {
console.log(`\n--- Record ${index + 1} ---`);
console.log(`ID: ${record.id}`);
console.log(`Name: ${record.first_name} ${record.last_name}`);
console.log(`Birth Date: ${record.birth_date}`);
console.log(`Birth Time: ${record.birth_time}`);
console.log(`Birth Place: ${record.birth_place}`);
console.log(`Created At: ${record.created_at}`);
if (record.face_image_path) {
console.log(`Face Image: ${record.face_image_path}`);
}
if (record.hand_image_path) {
console.log(`Hand Image: ${record.hand_image_path}`);
}
if (record.analysis_result) {
console.log('Analysis Result: Data exists (not showing full content for brevity)');
}
});
} else {
console.log('\n📝 No records found in the users table yet');
console.log('This is normal if you haven\'t submitted any forms yet');
}
console.log('\n✅ Supabase integration is working correctly!');
} catch (error) {
console.error('❌ Error:', error.message);
process.exit(1);
}
}
>>>>>>> 4939126ee5c953624a0df2c93b0c18153fd12173
checkSupabaseData();