Skip to content

Commit

Permalink
fix: array append/remove
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <[email protected]>
  • Loading branch information
mattkrick committed Jul 3, 2024
1 parent 81d68b7 commit f4f5ede
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ const updateOrgFeatureFlag: MutationResolvers['updateOrgFeatureFlag'] = async (
// RESOLUTION
await getKysely()
.updateTable('Organization')
.$if(addFlag, (db) => db.set({featureFlags: sql`ARRAY_APPEND("featureFlags",${flag})`}))
.$if(addFlag, (db) => db.set({featureFlags: sql`arr_append_uniq("featureFlags",${flag})`}))
.$if(!addFlag, (db) =>
db.set({
featureFlags: sql`array_cat(
"featureFlags"[1:array_position("featureFlags",${flag})-1],
"featureFlags"[array_position("featureFlags",${flag})+1:]
)`
featureFlags: sql`ARRAY_REMOVE("featureFlags",${flag})`
})
)
.where('id', 'in', orgIds)
Expand Down

0 comments on commit f4f5ede

Please sign in to comment.