Populate does not work for a certain case ('populate = with')

Basically I have this endpoint that creates a booking and I cannot figure out why taskInstances does not get populated. Also the choice of the word 'with' makes searching for this particular problem on the internet very hard. If I had the task of coming up with a name I would probably just stick with the classic 'populate'. I have provided you with a slice of my repo modified for the easy reproduction of this exact case: https://github.com/XenoWad01/drizzle-with-repro Just ctrl + shift + f for Now why in gods name does this return [] when in studio there clearely are task-instances????? to see where the populate should happen and does not. I have even checked studio and the taskInstances are for sure there so this might just be an issue with populate or maybe on my part, not sure. You can find the schema inside packages/bookd-api/db/schema/ and everything else related to drizzle's setup inside packages/bookd-api/db. Steps to set up repo (I am assuming you have docker compose and Docker desktop set up for this): 1) go inside packages/bookd-api/ and make a .env file and copy over everything from the .env.example inside it. 2) docker compose up -d 3) yarn run install at the project root 4) yarn run dev 5) You can now navigate to http://localhost:3000/ (or just refresh the page) to trigger the reproduction case. The message mentioned above with Now why in gods name does this return [] when in studio there clearely are task-instances????? -> should be logged to the terminal with the value of taskInstances being []. You can repeat this endlessly it just creates everything needed for this step to happen on each page refresh (with randomized data for everything that for example needs to be unique). Sorry if the reproduction repo is a bit large, I figured if there's something wrong with my setup It would provide contextual information that might be needed. Thank you for your time!
GitHub
GitHub - XenoWad01/drizzle-with-repro
Contribute to XenoWad01/drizzle-with-repro development by creating an account on GitHub.
1 Reply
The Cultured One
The Cultured OneOP•12mo ago
Let me know if you need more info from me to diagnose this.
drizzle-kit: v0.20.7
drizzle-orm: v0.29.1
drizzle-kit: v0.20.7
drizzle-orm: v0.29.1
And if you need to look inside the db with studio for example you can just run
yarn run studio
yarn run studio
at the root of the project I forgot to mention some populates work for example aditionalServiceInstance works just fine. Ok I debugged this myself a bit more... Turns out I did some stupid stuff and I wasnt really awaiting the create instance operation to finish before moving on. Basically I did a forEach(async stuff => {createstuff}) and what i shouldhave done was
//either one of these
await Promise.all(stuff.map(async thing => ...))
for (const thing of stuff) { await ... }

// Though Promise.all is probably more efficient
//either one of these
await Promise.all(stuff.map(async thing => ...))
for (const thing of stuff) { await ... }

// Though Promise.all is probably more efficient
Sorry for jumping the boat and saying it's a drizzle problem when it was really a me problem 😛 I would consider this solved but I dont know how to use the emote that makes this thread resolved.
Want results from more Discord servers?
Add your server