File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed
frameworks/TypeScript/elysia Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change 1313 "compile" : " bun build --compile --minify --target bun --outfile server src/index.ts"
1414 },
1515 "dependencies" : {
16- "elysia" : " ^1.2.6 " ,
16+ "elysia" : " ^1.2.9 " ,
1717 "postgres" : " ^3.4.5"
1818 }
1919}
Original file line number Diff line number Diff line change @@ -25,16 +25,14 @@ export const findThenRand = (id: number) =>
2525 } ,
2626 ) ;
2727
28- export const bulkUpdate = ( worlds : World [ ] ) =>
29- sql `UPDATE world SET randomNumber = (update_data.randomNumber)::int
30- FROM (VALUES ${ worlds
31- . sort ( ( a , b ) => {
32- if ( a . id < b . id ) return - 1 ;
28+ export const bulkUpdate = ( worlds : World [ ] ) => {
29+ const sorted = worlds . toSorted ( ( a , b ) => a . id - b . id ) ;
30+
31+ const values = new Array ( sorted . length ) ;
32+ for ( let i = 0 ; i < sorted . length ; i ++ )
33+ values [ i ] = [ sorted [ i ] . id , sorted [ i ] . randomNumber ] ;
3334
34- return 1 ;
35- } )
36- . map ( ( world ) => [
37- world . id ,
38- world . randomNumber ,
39- ] ) } ) AS update_data (id, randomNumber)
40- WHERE world.id = (update_data.id)::int` ;
35+ sql `UPDATE world SET randomNumber = (update_data.randomNumber)::int
36+ FROM (VALUES ${ values } ) AS update_data (id, randomNumber)
37+ WHERE world.id = (update_data.id)::int` ;
38+ } ;
You can’t perform that action at this time.
0 commit comments