File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
app/routes/users+/$username_+ Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export async function loader({ params }: Route.LoaderArgs) {
3232 updatedAt : true ,
3333 images : {
3434 select : {
35+ id : true ,
3536 altText : true ,
3637 objectKey : true ,
3738 } ,
@@ -123,7 +124,7 @@ export default function NoteRoute({
123124 < div className = { `${ displayBar ? 'pb-24' : 'pb-12' } overflow-y-auto` } >
124125 < ul className = "flex flex-wrap gap-5 py-5" >
125126 { loaderData . note . images . map ( ( image ) => (
126- < li key = { image . objectKey } >
127+ < li key = { image . id } >
127128 < a href = { getNoteImgSrc ( image . objectKey ) } >
128129 < Img
129130 src = { getNoteImgSrc ( image . objectKey ) }
Original file line number Diff line number Diff line change @@ -54,19 +54,21 @@ async function seed() {
5454
5555 // Add images to note
5656 const noteImageCount = faker . number . int ( { min : 1 , max : 3 } )
57- for ( let imageIndex = 0 ; imageIndex < noteImageCount ; imageIndex ++ ) {
58- const imgNumber = faker . number . int ( { min : 0 , max : 9 } )
59- const noteImage = noteImages [ imgNumber ]
60- if ( noteImage ) {
61- await prisma . noteImage . create ( {
57+ const selectedImages = faker . helpers . arrayElements (
58+ noteImages ,
59+ noteImageCount ,
60+ )
61+ await Promise . all (
62+ selectedImages . map ( ( noteImage ) =>
63+ prisma . noteImage . create ( {
6264 data : {
6365 noteId : note . id ,
6466 altText : noteImage . altText ,
6567 objectKey : noteImage . objectKey ,
6668 } ,
67- } )
68- }
69- }
69+ } ) ,
70+ ) ,
71+ )
7072 }
7173 }
7274 console . timeEnd ( `👤 Created ${ totalUsers } users...` )
You can’t perform that action at this time.
0 commit comments