Generating with MeanJS and Yeoman Generator
One of my favorite things with Yii is the Gii (Generator).
With a few clicks I could simply add a few Models/Controllers/Views (or all of the above), then build/customize those.
MeanJS uses the Yeoman/Yo generator to make this happen.
After installing Yeoman generator (which I believe we already installed when we installed MeanJS) via:
1
npm install -g yo
Now to install the MeanJS generator package:
1
npm install -g generator-meanjs
Basic CRUD
For those who are not familiar with the concept, CRUD stands for - Create, Read, Update & Delete.
These are the basics one needs to present & manipulate data on a website, and a lot of web frameworks generate CRUDs as sort of a first-step.
Let's create our first CRUD:
1
yo meanjs:crud-module firstmodule
After selecting the supplemental folder to include in the Angular Module, and whether or not the module should be added to the menu, a bunch of files are generated.
Very Important: The crud-module generates both the Server side & Client files.
The Module Structure was explained thoroughly on Basics of MeanJS.
The crud-module is the all encompassing, there are also sub generators:
- angular-module
- angular-route
- angular-controller
- angular-view
- angular-service
- angular-directive
- angular-filter
- angular-config
- angular-test
- express-model
- express-controller
- express-route
- express-test
Those names are pretty self explanatory, so I don't see much need to go deeper there.
More information about Yeoman generator specifically used for MeanJS can be found here
As you can probably notice, this article came out a bit shorter than expected, this is mainly due to time constraints.
I'd like to continue and develop under MeanJS, as I see a lot of interest on the subject.
There are also a few other frameworks that I started reading about that might be a part of some future articles (some are fairly similar).
Bonus info: MeanJS was on the Changelog podcast!, very cool.