Skip to content

Commit

Permalink
Merge pull request #56 from SystemEngineeringTeam/issue/52-upsert-use…
Browse files Browse the repository at this point in the history
…r-table

feat: ユーザーテーブルにユーザを追加する
  • Loading branch information
SatooRu65536 authored Nov 5, 2024
2 parents e83cfac + a3c3c94 commit ceb4282
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/utils/upsertUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { supabase } from './supabase/client';
import type { Tables } from '@/types/supabase';

const upsertUser = async (name: string, uid: string): Promise<Tables<'user'> | undefined> => {
const { data, error: userError } = await supabase.from('user').upsert({ name, uid }).select('*');
if (userError !== null || data.length === 0) {
console.error(userError);
return undefined;
}

return data[0];
};

export default upsertUser;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "public"."user" drop constraint "user_pkey"
drop index if exists "public"."user_pkey"

0 comments on commit ceb4282

Please sign in to comment.