I’m new to Meteor and coming from Rails/Python background, already I am confused with how to organize my code. Suppose I have a bunch of models, things like User, List, Task, etc. Instead of a bunch of helpers and throwing the HTML templates into app.html, is there a more organized approach where each model gets its own .js / .jsx file?
I have looked into using React but can’t find more than a most basic Meteor/React example.
Models are a bit tricky in Meteor because there isn’t a go-to ORM. I’ve rolled my own like this example. The concept is to share them on both the client and server. The client uses it to run it’s ‘simulation’ or ‘stub’ and the server copy does the real mutation.
For general app layout checkout my React-ive Meteor repo to see how you can organize your Blaze or React components/pages.
I would recommend reading this article to get the hang of template level subscriptions. It was very common to do this in the router and now the best practice is generally to let the template/component take care of it: https://www.discovermeteor.com/blog/template-level-subscriptions/
I also just posted a new way to structure user actions and data manipulation, it might be worth reading as well (this will be rolled into React-ive Meteor in the next few days):
The nice thing is that Meteor lets you structure you app how you like. The bad part is that it takes a while to figure out what works best
I have been creating EJSON custom types for my models. It has been really useful and has allowed for some pretty clean code. You can create all the methods you want and make them run on the server or client or both. Here is an example:
Along with the other suggestions, there are packages that I’ve used that attempt to address this problem. I’ve tried:
minimongoid - If you’ve used the mongoid gem, this might look familiar. It’s nowhere near the capability of mongoid, but it was making good progress when activity slowed down. Might not be a good bet because it’s not very active.
Combination of collection-helpers and collection-hooks - You can get model-like behavior in your collections by using these packages. This is my preferred approach at the moment.
astronomy - Astronomy recently surfaced and looks to be very comprehensive and promising.