lib/utils/helpers.js
function normalizeAttributes(attrs, strip) {

            // map for converting SQL types to Sequelize DataTypes.
            var map = {
                    TINYINT: 'BOOLEAN',
                    DATETIME: 'DATE',
                    TIMESTAMP: 'DATE',
                    'VARCHAR BINARY': 'STRING.BINARY',
                    'TINYBLOB': 'BLOB',
                    VARCHAR: 'STRING[LEN]',
                    'INTEGER UNSIGNED ZEORFILL': 'INTEGER[LEN].UNSIGNED.ZEROFILL',
                    'INTEGER UNSIGNED': 'INTEGER[LEN].UNSIGNED',
                    'INTEGER ZEROFILL': 'INTEGER[LEN].ZEROFILL',
                    INTEGER: 'INTEGER[LEN]',
                    'FLOAT UNSIGNED ZEORFILL': 'FLOAT[LEN].UNSIGNED.ZEROFILL',
                    'FLOAT ZEROFILL': 'FLOAT[LEN].ZEROFILL',
                    'FLOAT UNSIGNED': 'FLOAT[LEN].UNSIGNED',
                    FLOAT: 'FLOAT[LEN]',
                    'BIGINT UNSIGNED ZEORFILL': 'BIGINT[LEN].UNSIGNED.ZEROFILL',
                    'BIGINT ZEROFILL': 'BIGINT[LEN].ZEROFILL',
                    'BIGINT UNSIGNED': 'BIGINT[LEN].UNSIGNED',
                    BIGINT: 'BIGINT[LEN]',
                    DECIMAL: 'DECIMAL[LEN]',
                    ENUM: 'ENUM'
                },
                mapKeys = Object.keys(map);

            strip = strip || [];
            strip.push('Model');

            // convert and format to Sequelize Model Type.
            function getType(type, len, name) {

                if(!type) return undefined;
                type = type.split('(')[0];

                if(map[type]){
                    var tmp = map[type];
                    if(len && !_.contains([255, 11], len)) len = '(' + len + ')';
                    else len = '';
                    type = tmp.replace('[LEN]', len);
                }

                return type;
            }

            // iterate properties.
            for(var prop in attrs) {

                if(attrs.hasOwnProperty(prop)){

                    var attr = attrs[prop],
                        type = attr.type,
                        prec = type._precision && type._scale ? type._precision + ',' + type._scale : false,
                        len = prec ? prec : type._length || false;

                    // strip properties.
                    strip.forEach(function (s) {
                        if(attr[s]) delete attr[s];
                    });

                    if(attr.validate && attr.validate._checkEnum)
                        type = 'ENUM';

                    if(!type._binary && type._length)
                        type = 'VARCHAR';

                    if(type._binary)
                        type = 'VARCHAR BINARY';

                    if(_.contains(['INTEGER', 'FLOAT', 'BIGINT'], type._typeName)){
                        var tmp = '';
                        tmp = type._unsigned ? tmp += ' UNSIGNED' : tmp;
                        tmp = type._zerofill ? tmp += ' ZEROFILL' : tmp;
                        type = type._typeName + tmp;

                    }

                    if(_.isObject(type))
                        type = type._typeName;

                    attrs[prop].type = getType(type, len, attr.fieldName);

                }

            }

            return attrs;
        }
function normalizeAttributes(attrs, strip) {

            // map for converting SQL types to Sequelize DataTypes.
            var map = {
                    TINYINT: 'BOOLEAN',
                    DATETIME: 'DATE',
                    TIMESTAMP: 'DATE',
                    'VARCHAR BINARY': 'STRING.BINARY',
                    'TINYBLOB': 'BLOB',
                    VARCHAR: 'STRING[LEN]',
                    'INTEGER UNSIGNED ZEORFILL': 'INTEGER[LEN].UNSIGNED.ZEROFILL',
                    'INTEGER UNSIGNED': 'INTEGER[LEN].UNSIGNED',
                    'INTEGER ZEROFILL': 'INTEGER[LEN].ZEROFILL',
                    INTEGER: 'INTEGER[LEN]',
                    'FLOAT UNSIGNED ZEORFILL': 'FLOAT[LEN].UNSIGNED.ZEROFILL',
                    'FLOAT ZEROFILL': 'FLOAT[LEN].ZEROFILL',
                    'FLOAT UNSIGNED': 'FLOAT[LEN].UNSIGNED',
                    FLOAT: 'FLOAT[LEN]',
                    'BIGINT UNSIGNED ZEORFILL': 'BIGINT[LEN].UNSIGNED.ZEROFILL',
                    'BIGINT ZEROFILL': 'BIGINT[LEN].ZEROFILL',
                    'BIGINT UNSIGNED': 'BIGINT[LEN].UNSIGNED',
                    BIGINT: 'BIGINT[LEN]',
                    DECIMAL: 'DECIMAL[LEN]',
                    ENUM: 'ENUM'
                },
                mapKeys = Object.keys(map);

            strip = strip || [];
            strip.push('Model');

            // convert and format to Sequelize Model Type.
            function getType(type, len, name) {

                if(!type) return undefined;
                type = type.split('(')[0];

                if(map[type]){
                    var tmp = map[type];
                    if(len && !_.contains([255, 11], len)) len = '(' + len + ')';
                    else len = '';
                    type = tmp.replace('[LEN]', len);
                }

                return type;
            }

            // iterate properties.
            for(var prop in attrs) {

                if(attrs.hasOwnProperty(prop)){

                    var attr = attrs[prop],
                        type = attr.type,
                        prec = type._precision && type._scale ? type._precision + ',' + type._scale : false,
                        len = prec ? prec : type._length || false;

                    // strip properties.
                    strip.forEach(function (s) {
                        if(attr[s]) delete attr[s];
                    });

                    if(attr.validate && attr.validate._checkEnum)
                        type = 'ENUM';

                    if(!type._binary && type._length)
                        type = 'VARCHAR';

                    if(type._binary)
                        type = 'VARCHAR BINARY';

                    if(_.contains(['INTEGER', 'FLOAT', 'BIGINT'], type._typeName)){
                        var tmp = '';
                        tmp = type._unsigned ? tmp += ' UNSIGNED' : tmp;
                        tmp = type._zerofill ? tmp += ' ZEROFILL' : tmp;
                        type = type._typeName + tmp;

                    }

                    if(_.isObject(type))
                        type = type._typeName;

                    attrs[prop].type = getType(type, len, attr.fieldName);

                }

            }

            return attrs;
        }
function normalizeAttributes ( attrs , strip ) { // map for converting SQL types to Sequelize DataTypes. var map = { TINYINT : 'BOOLEAN' , DATETIME : 'DATE' , TIMESTAMP : 'DATE' , 'VARCHAR BINARY' : 'STRING.BINARY' , 'TINYBLOB' : 'BLOB' , VARCHAR : 'STRING[LEN]' , 'INTEGER UNSIGNED ZEORFILL' : 'INTEGER[LEN].UNSIGNED.ZEROFILL' , 'INTEGER UNSIGNED' : 'INTEGER[LEN].UNSIGNED' , 'INTEGER ZEROFILL' : 'INTEGER[LEN].ZEROFILL' , INTEGER : 'INTEGER[LEN]' , 'FLOAT UNSIGNED ZEORFILL' : 'FLOAT[LEN].UNSIGNED.ZEROFILL' , 'FLOAT ZEROFILL' : 'FLOAT[LEN].ZEROFILL' , 'FLOAT UNSIGNED' : 'FLOAT[LEN].UNSIGNED' , FLOAT : 'FLOAT[LEN]' , 'BIGINT UNSIGNED ZEORFILL' : 'BIGINT[LEN].UNSIGNED.ZEROFILL' , 'BIGINT ZEROFILL' : 'BIGINT[LEN].ZEROFILL' , 'BIGINT UNSIGNED' : 'BIGINT[LEN].UNSIGNED' , BIGINT : 'BIGINT[LEN]' , DECIMAL : 'DECIMAL[LEN]' , ENUM : 'ENUM' } , mapKeys = Object . keys ( map ) ; strip = strip || [ ] ; strip . push ( 'Model' ) ; // convert and format to Sequelize Model Type. function getType ( type , len , name ) { if ( ! type ) return undefined ; type = type . split ( '(' ) [ 0 ] ; if ( map [ type ] ) { var tmp = map [ type ] ; if ( len && ! _ . contains ( [ 255 , 11 ] , len ) ) len = '(' + len + ')' ; else len = '' ; type = tmp . replace ( '[LEN]' , len ) ; } return type ; } // iterate properties. for ( var prop in attrs ) { if ( attrs . hasOwnProperty ( prop ) ) { var attr = attrs [ prop ] , type = attr . type , prec = type . _precision && type . _scale ? type . _precision + ',' + type . _scale : false , len = prec ? prec : type . _length || false ; // strip properties. strip . forEach ( function ( s ) { if ( attr [ s ] ) delete attr [ s ] ; } ) ; if ( attr . validate && attr . validate . _checkEnum ) type = 'ENUM' ; if ( ! type . _binary && type . _length ) type = 'VARCHAR' ; if ( type . _binary ) type = 'VARCHAR BINARY' ; if ( _ . contains ( [ 'INTEGER' , 'FLOAT' , 'BIGINT' ] , type . _typeName ) ) { var tmp = '' ; tmp = type . _unsigned ? tmp += ' UNSIGNED' : tmp ; tmp = type . _zerofill ? tmp += ' ZEROFILL' : tmp ; type = type . _typeName + tmp ; } if ( _ . isObject ( type ) ) type = type . _typeName ; attrs [ prop ] . type = getType ( type , len , attr . fieldName ) ; } } return attrs ; }
Normalize property attributes primarily the type.
@memberof Helpers
@param {object} attrs - the attributes to be parsed.
@param {array} strip - an array of keys to strip/remove.
@returns {object}
Normalize property attributes primarily the type .