Repository navigation
Expand file tree
/
Copy pathtest-record-creation.js
More file actions
51 lines (42 loc) Β· 1.8 KB
/
Copy pathtest-record-creation.js
File metadata and controls
51 lines (42 loc) Β· 1.8 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
import { createClient } from '@supabase/supabase-js';
// Initialize Supabase client with service role key
const supabaseUrl = 'https://spjnakucrrjvvdsahpom.supabase.co';
const supabaseServiceKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNwam5ha3VjcnJqdnZkc2FocG9tIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc1MjkwOTA4NSwiZXhwIjoyMDY4NDg1MDg1fQ.kJWcHkRz8NPuK-JfboT_Eiyqm_yMIPmQFm3kJG0PO6Y';
const supabase = createClient(supabaseUrl, supabaseServiceKey);
async function testRecordCreation() {
console.log('π§ͺ Testing record creation...');
try {
// Test record creation exactly like the form does
const { data: newRecord, error } = await supabase
.from('records')
.insert({
subject: 'Computer Science',
description: 'Test record for SCV subject - database concepts and implementation',
record_date: '2025-08-04'
})
.select();
if (error) {
console.log('β Error creating record:', error.message);
} else {
console.log('β
Record created successfully!');
console.log('π Created record:', newRecord[0]);
}
// Also test fetching existing records
console.log('\nπ Fetching all records...');
const { data: allRecords, error: fetchError } = await supabase
.from('records')
.select('*')
.order('record_date', { ascending: false });
if (fetchError) {
console.log('β Error fetching records:', fetchError.message);
} else {
console.log('β
Found record entries:', allRecords.length);
allRecords.forEach((record, index) => {
console.log(` ${index + 1}. ${record.subject} - ${record.record_date}`);
});
}
} catch (err) {
console.error('β Unexpected error:', err);
}
}
testRecordCreation().catch(console.error);