Jaeden
10/06/2021, 3:57 PMcode: "23505"
details: null
hint: null
message: "duplicate key value violates unique constraint \"watchlists_pkey\""
silentworks
10/06/2021, 4:07 PMsilentworks
10/06/2021, 4:07 PMJaeden
10/06/2021, 4:12 PMJaeden
10/06/2021, 4:12 PMJaeden
10/06/2021, 4:37 PMsilentworks
10/06/2021, 4:41 PMsilentworks
10/06/2021, 4:42 PMJaeden
10/06/2021, 5:03 PMconst addProjectToWatchlist = async (userId, watchlistId, collectedArray) => {
return await supabase
.from('watchlists')
.upsert({ id: watchlistId, author_id: userId, collected: collectedArray })
}
Jaeden
10/06/2021, 5:03 PMauthor_id
is a foreign key relation to the auth users databaseJaeden
10/06/2021, 5:04 PMcollected
is a simple JSONB arrayJaeden
10/06/2021, 5:05 PMid
is the primary key, which i pass to the upsert method (The ID matches with the row inside the watchlists
table and isn't a random ID.) Should this be update
instead 🤔?Jaeden
10/06/2021, 5:06 PMJaeden
10/06/2021, 5:08 PMconst addProjectToWatchlist = async (userId, watchlistId, collectedArray) => {
return await supabase
.from('watchlists')
.upsert({ id: watchlistId, author_id: userId, collected: collectedArray }, { onConflict: id })
}
Jaeden
10/06/2021, 5:23 PM