How can I efficiently create multiple models in my app?

0
21
Asked By CreativeStar23 On

Hi everyone! I'm working on an app that has numerous model files, each representing a business entity. These models are later used as ORMs to perform CRUD operations. I'm searching for a way to create all these models at once and use them across app restarts. My goal is to find a solution that works with JavaScript, but I'm also curious about the underlying concepts. Is this feasible?

4 Answers

Answered By FileGuru12 On

Consider loading all your model files into memory at startup. Keep track of the file handles, make necessary edits to the in-memory files, and save those changes back to the disk as needed. You could even create a temporary file containing all the current edits combined into one.

Answered By TechSavvy88 On

You might want to clarify what you're aiming for. Typically, when you use an ORM, models are defined in your codebase. You write and deploy them once, so they're instantiated whenever your app starts up.

Answered By QuickCoder77 On

If you're working with something like ERP systems, having 200-400 tables is common. For smaller projects, around 20 tables is typical. It's important to evaluate the need for loading so many models at startup.

Answered By DataWise22 On

I'm not sure why you need to persist models across app restarts. Normally, you create and destroy model instances based on your business logic. While it's possible to create many instances quickly, it's generally better to load them from the database on demand rather than all at once when the app starts. You might want to explore optimizing your database or even implementing some caching solutions.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.