File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 160160 "add" : " Add" ,
161161 "cannotUndo" : " This action cannot be undone." ,
162162 "close" : " Close" ,
163+ "components" : {
164+ "multiitem" : {
165+ "new" : " Create new: \" {0}\" " ,
166+ "placeholder" : " Start typing..."
167+ }
168+ },
163169 "create" : " Create" ,
164170 "date" : " Date" ,
165171 "delete" : " Delete" ,
181187 "servers" : " Servers" ,
182188 "srLoading" : " Loading…" ,
183189 "tags" : " Tags" ,
184- "today" : " Today" ,
185- "components" : {
186- "multiitem" : {
187- "placeholder" : " Start typing..." ,
188- "new" : " Create new: \" {0}\" "
189- }
190- }
190+ "today" : " Today"
191191 },
192192 "drop" : {
193193 "desc" : " An open-source game distribution platform built for speed, flexibility and beauty." ,
Original file line number Diff line number Diff line change @@ -16,10 +16,19 @@ export default defineEventHandler(async (h3) => {
1616
1717 const game = await prisma . game . findUnique ( {
1818 where : { id } ,
19- select : { id : true } ,
19+ select : { id : true , tags : { select : { id : true } } } ,
2020 } ) ;
2121 if ( ! game ) throw createError ( { statusCode : 404 , message : "Game not found" } ) ;
2222
23+ const tagSet = new Set ( game . tags . map ( ( v ) => v . id ) ) ;
24+ const toConnect = body . tags . filter ( ( v ) => ! tagSet . has ( v ) ) ;
25+
26+ const bodyTagSet = new Set ( body . tags ) ;
27+ const toDisconnect = tagSet
28+ . values ( )
29+ . filter ( ( v ) => ! bodyTagSet . has ( v ) )
30+ . toArray ( ) ;
31+
2332 // SAFETY: Okay to disable due to check above
2433 // eslint-disable-next-line drop/no-prisma-delete
2534 await prisma . game . update ( {
@@ -28,7 +37,8 @@ export default defineEventHandler(async (h3) => {
2837 } ,
2938 data : {
3039 tags : {
31- connect : body . tags . map ( ( e ) => ( { id : e } ) ) ,
40+ connect : toConnect . map ( ( e ) => ( { id : e } ) ) ,
41+ disconnect : toDisconnect . map ( ( e ) => ( { id : e } ) ) ,
3242 } ,
3343 } ,
3444 } ) ;
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments