node package manager



It is a yeoman generator to generate automatically code about dao, routes, angular resources, angular controllers, mongoose models.


First install yeoman

npm install -g yeoman

Then create a Gruntfile.js needed by yeoman to find yocrud

touch Gruntfile.js

Finally install yocrud

npm install yocrud


You can choose to invoke a single generator among 4 generators: dao, route, angular, model or to invoke them all in series.

If you want to invoke all generatos run

yeoman init yocrud <name>

where <name> is the name of your app.

For example, if you mant an app to handle books, run yeoman init yocrud Book.

Otherwise you can invoke a single generator:

yeoman init yocrud:<name of generator> <name>

where <name of a generator> can be dao, angular, route or model.

Below you can find documentation about the single generators.

Model generator

This generator creates a file that contains model declarations for mongoose. Tipically, if you run yeoman init yocrud:model Book, it generates the file model/Book.js and its content will be:

var mongoose = require('mongoose')
,       Schema = mongoose.Schema
,       DB=require('./DB.js')
function BookSchema=new Schema({},{ strict:false  })
mongoose.model( 'Book' , BookSchema )
function Book(){
        return DB.model( 'Book' )

Dao generator

It generates code to query and save a model to MongoDb via mongoose.

If you run yeoman init yocrud:dao Book it will generate the file dao/BookDao.js and its content will be

var Model=require('../model/'+Book+'js')
function BookDao(){}, cb){
    var model=new Model(obj)
BookDao.prototype.query(query, cb){
BookDao.prototype.get(query, cb){
BookDao.prototype.update(query, update, cb){
    Model.update(query, update,cb)

Route generator

It generates code that consists in http handlers (according to REST style).

If you run yeoman init yocrud:route Book it will generates route/BookRoute.js whose content is:

var ModelDao=require('../dao/'+Book+'Dao.js')
function BookRoute=function(options){'/'+Book,this.get)'/'+Book+'/:_id',this.getSingle)'/'+Book+'/:_id',this.update)'/'+Book,


  • example app
  • better integration with angular
  • USAGE files
  • generation of a index.html page
  • better integration with bootstrap
  • better