Scaffold 1:n relations

Just wanted to say congrats to this project. Looks very promising. I am doing my first steps here and have two questions. Hope you can point me to the right direction.

I played around with 1:n and m:n relations. The latter was a bit of a pain to get running btw. But lets get back to 1:n. Is scaffolding supported like with a drop down on the N side?

Then i have some issues to get intellisense working (with webstorn). I dont have any support in the seed.js on PrismaClient. Of course i am quite new to Prisma, so this might be as well a knowledge issue on my side. My ORM background is more Java/JPA related. So this type safety is always tricky. I already added TS support for my RW project. So do you guys have any hints for on this one?

One more thing… the seed is only run with the CLI command or is it run generally on starting the dev server?

Thanks.
marc

1 Like

Welcome!

A scaffold with a relation will simply show as a text box where you can enter the ID of the related record, no dropdown. Adding a dropdown can result in severe performance issues (imagine a lookup of 1,000 records). Which could be mitigated with something like a typeahead search, but that’s just more and more complexity that needs to be maintained by both us and the developer using the framework. Those of us that worked on scaffolds came from a Rails background and in our experience, scaffolds are used less and less as apps get bigger and the dev develops more experience with the framework, so we didn’t want to put too much effort into building a complete admin-backend solution. There are some projects out there for this, though!

I can’t speak to intellisense support, sorry!

seed.js is never run automatically, it’s meant to be run as-needed, usually once when someone checks out the app for the first time and is going to start working on it, or doing a re-build of the database for whatever reason. It’s meant to contain data that’s essential for your app to run, not build out an entire development dataset that you want to be around for local testing. In theory you would run it once when you deploy to a new environment to bootstrap your app (creating an admin user, for example). If you later need more seed data, you should make sure that any creates are idempotent (check for existence of the record you’re about to create, to make sure you don’t create it again) so that you can run the seed file again later when more data is added.

Thanks for your great reply, Rob. Get what you are saying about scaffolds. You most likely will grow out of it, but to be honest, it was one of the selling points to look deeper into it. Apart from a fast start, you get some nice blueprints how to structure your code, which is always a good idea when one is coming from a different language/framework context.

Hope to solve this intellisense thing. This is the part where i miss java from time to time. No hassle with types because its just not available without.

2 Likes