File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
supabase/functions/fetch-scrobbles Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -25,20 +25,20 @@ export class TableHooman extends DbSupabaseTable {
2525 throw new Error ( "Error fetching hooman: " + JSON . stringify ( error ) ) ;
2626 }
2727
28- if ( null !== data ) {
28+ if ( data ) {
2929 return data . id ;
3030 }
3131
32- const { error : errorCrate } = await this . getSupabase ( )
32+ const { data : insertData , error : insertError } = await this . getSupabase ( )
3333 . from ( this . tableName )
34- . insert ( {
35- [ columnName . lastfm_user ] : lastFmUser ,
36- } ) ;
34+ . insert ( { [ columnName . lastfm_user ] : lastFmUser } )
35+ . select ( "id" )
36+ . maybeSingle < { id : string } > ( ) ;
3737
38- if ( errorCrate ) {
39- throw new Error ( "Error create new hooman: " + JSON . stringify ( errorCrate ) ) ;
38+ if ( insertError || ! insertData ) {
39+ throw new Error ( "Error creating hooman: " + JSON . stringify ( insertError ) ) ;
4040 }
4141
42- return this . findOrCreateByLastFmUser ( lastFmUser ) ;
42+ return insertData . id ;
4343 }
4444}
You can’t perform that action at this time.
0 commit comments