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 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.