-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_update.mjs
More file actions
49 lines (38 loc) · 1.42 KB
/
test_update.mjs
File metadata and controls
49 lines (38 loc) · 1.42 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
import { createClient } from '@supabase/supabase-js'
const supabaseUrl = 'https://rlrzmqbdpjkpxbfdgnlm.supabase.co'
const serviceKey = 'sb_secret_QO7_ivKEVxKj4ABjtxbYgQ_x2s-pEqA'
const supabase = createClient(supabaseUrl, serviceKey, {
auth: { persistSession: false, autoRefreshToken: false }
})
async function testUpdate() {
// First get current data
const { data: before } = await supabase
.from('resume')
.select('id, data')
.eq('section', 'resume')
.single()
console.log('Before - work count:', before.data.work.length)
// Add a test item
const updatedData = {
...before.data,
work: [...before.data.work, { company: 'TEST_COMPANY', title: 'Test', years: '2024', image: '', description: ['test'] }]
}
console.log('Updating with work count:', updatedData.work.length)
// Try update
const { data: updateResult, error: updateError } = await supabase
.from('resume')
.update({ data: updatedData })
.eq('id', before.id)
.select()
console.log('Update error:', updateError)
console.log('Update result:', JSON.stringify(updateResult))
// Check if it actually updated
const { data: after } = await supabase
.from('resume')
.select('id, data')
.eq('section', 'resume')
.single()
console.log('After - work count:', after.data.work.length)
console.log('TEST_COMPANY added?', after.data.work.some(w => w.company === 'TEST_COMPANY'))
}
testUpdate()