lib/generators.js
function generateModel(path, modelName, modelFields, generateMethod, ts, cb) {
    var fields = formatTools.getFieldsForModelTemplate(modelFields);
    var schemaName = modelName + 'Schema';

    var extension = (ts) ? 'ts' : 'js';
    var model = ft.loadTemplateSync('model.' + extension);
    model = model.replace(/{modelName}/, modelName);
    model = model.replace(/{schemaName}/g, schemaName);
    model = model.replace(/{fields}/, fields);

    if (generateMethod === 't') {
        ft.createDirIfIsNotDefined(path, 'models', function () {
            ft.writeFile(path + '/models/' + modelName + 'Model.' + extension, model, null, cb);
        });
    } else {
        ft.createDirIfIsNotDefined(path, modelName, function () {
            ft.writeFile(path + '/' + modelName + '/' + modelName + 'Model.' + extension, model, null, cb);
        });
    }
}
function generateModel(path, modelName, modelFields, generateMethod, ts, cb) {
    var fields = formatTools.getFieldsForModelTemplate(modelFields);
    var schemaName = modelName + 'Schema';

    var extension = (ts) ? 'ts' : 'js';
    var model = ft.loadTemplateSync('model.' + extension);
    model = model.replace(/{modelName}/, modelName);
    model = model.replace(/{schemaName}/g, schemaName);
    model = model.replace(/{fields}/, fields);

    if (generateMethod === 't') {
        ft.createDirIfIsNotDefined(path, 'models', function () {
            ft.writeFile(path + '/models/' + modelName + 'Model.' + extension, model, null, cb);
        });
    } else {
        ft.createDirIfIsNotDefined(path, modelName, function () {
            ft.writeFile(path + '/' + modelName + '/' + modelName + 'Model.' + extension, model, null, cb);
        });
    }
}
function generateModel ( path , modelName , modelFields , generateMethod , ts , cb ) { var fields = formatTools . getFieldsForModelTemplate ( modelFields ) ; var schemaName = modelName + 'Schema' ; var extension = ( ts ) ? 'ts' : 'js' ; var model = ft . loadTemplateSync ( 'model.' + extension ) ; model = model . replace ( / {modelName} / , modelName ) ; model = model . replace ( / {schemaName} / g , schemaName ) ; model = model . replace ( / {fields} / , fields ) ; if ( generateMethod === 't' ) { ft . createDirIfIsNotDefined ( path , 'models' , function ( ) { ft . writeFile ( path + '/models/' + modelName + 'Model.' + extension , model , null , cb ) ; } ) ; } else { ft . createDirIfIsNotDefined ( path , modelName , function ( ) { ft . writeFile ( path + '/' + modelName + '/' + modelName + 'Model.' + extension , model , null , cb ) ; } ) ; } }
Generate a Mongoose model
@param {string} path
@param {string} modelName
@param {array} modelFields
@param {string} generateMethod
@param {boolean} ts generating code in TS
@param {function} cb
Generate a Mongoose model