lib/index.js
function sequelizeType(column, varName) {
    varName             = varName || 'DataTypes';       // DataTypes.INTEGER etc. prefix
    var enumValues = column.enumValues();
    var type = enumValues ? '.ENUM' : sequelizeTypes[column.type()].type;
    var realType = column.arrayDimension() >= 1 ? column.arrayType() : column.type(); // type or type of array (if array).
    var hasLength = sequelizeTypes[realType].hasLength;
    var hasPrecision = sequelizeTypes[realType].hasPrecision;
    var isObject = type && type.indexOf('.') !== -1;             // . ile başlıyorsa değişkene çevirmek için
    var details;
    var isArrayTypeObject;

    if (isObject) { type = varName + type; }

    details = function(num1, num2) {
        var detail = '';
        if (num1 >= 0 && num1 !== null && num2 && num2 !== null) {
            detail = '(' + num1 + ',' + num2 + ')';         // (5,2)
        } else if (num1 >= 0 && num1 !== null) {
            detail = '(' + num1 + ')';                      // (5)
        }

        return detail;
    };

    if (column.arrayDimension() >= 1) {
        isArrayTypeObject = sequelizeTypes[column.arrayType()].type.indexOf('.') !== -1;
        type += '(';
        if (column.arrayDimension() > 1) { type += new Array(column.arrayDimension()).join(varName + '.ARRAY('); } // arrayDimension -1 tane 'ARRAY(' yaz

        type += isArrayTypeObject ? varName : "'";
        type += sequelizeTypes[column.arrayType()].type;
        type += isArrayTypeObject ? '' : "'";
    }

    if (enumValues) {
        enumValues = util.inspect(enumValues.substring(1, enumValues.length - 1).split(',')); // Strip { and } -> make array -> makeJSON;
        enumValues = enumValues.substring(2, enumValues.length - 2); // Strip '[ ' and ' ]'
        type += '(' + enumValues + ')';
    }

    if (hasPrecision) {
        type += details(column.precision(), column.scale());
    }

    if (hasLength) {
        type += details(column.length());
    }

    if (column.arrayDimension() >= 1) {
        type += new Array(column.arrayDimension() + 1).join(')'); // arrayDimension -1 tane ) yaz
    }

    if (!isObject) {
        type = "'" + type + "'";
    }

    return type;
}
function sequelizeType(column, varName) {
    varName             = varName || 'DataTypes';       // DataTypes.INTEGER etc. prefix
    var enumValues = column.enumValues();
    var type = enumValues ? '.ENUM' : sequelizeTypes[column.type()].type;
    var realType = column.arrayDimension() >= 1 ? column.arrayType() : column.type(); // type or type of array (if array).
    var hasLength = sequelizeTypes[realType].hasLength;
    var hasPrecision = sequelizeTypes[realType].hasPrecision;
    var isObject = type && type.indexOf('.') !== -1;             // . ile başlıyorsa değişkene çevirmek için
    var details;
    var isArrayTypeObject;

    if (isObject) { type = varName + type; }

    details = function(num1, num2) {
        var detail = '';
        if (num1 >= 0 && num1 !== null && num2 && num2 !== null) {
            detail = '(' + num1 + ',' + num2 + ')';         // (5,2)
        } else if (num1 >= 0 && num1 !== null) {
            detail = '(' + num1 + ')';                      // (5)
        }

        return detail;
    };

    if (column.arrayDimension() >= 1) {
        isArrayTypeObject = sequelizeTypes[column.arrayType()].type.indexOf('.') !== -1;
        type += '(';
        if (column.arrayDimension() > 1) { type += new Array(column.arrayDimension()).join(varName + '.ARRAY('); } // arrayDimension -1 tane 'ARRAY(' yaz

        type += isArrayTypeObject ? varName : "'";
        type += sequelizeTypes[column.arrayType()].type;
        type += isArrayTypeObject ? '' : "'";
    }

    if (enumValues) {
        enumValues = util.inspect(enumValues.substring(1, enumValues.length - 1).split(',')); // Strip { and } -> make array -> makeJSON;
        enumValues = enumValues.substring(2, enumValues.length - 2); // Strip '[ ' and ' ]'
        type += '(' + enumValues + ')';
    }

    if (hasPrecision) {
        type += details(column.precision(), column.scale());
    }

    if (hasLength) {
        type += details(column.length());
    }

    if (column.arrayDimension() >= 1) {
        type += new Array(column.arrayDimension() + 1).join(')'); // arrayDimension -1 tane ) yaz
    }

    if (!isObject) {
        type = "'" + type + "'";
    }

    return type;
}
function sequelizeType ( column , varName ) { varName = varName || 'DataTypes' ; // DataTypes.INTEGER etc. prefix var enumValues = column . enumValues ( ) ; var type = enumValues ? '.ENUM' : sequelizeTypes [ column . type ( ) ] . type ; var realType = column . arrayDimension ( ) >= 1 ? column . arrayType ( ) : column . type ( ) ; // type or type of array (if array). var hasLength = sequelizeTypes [ realType ] . hasLength ; var hasPrecision = sequelizeTypes [ realType ] . hasPrecision ; var isObject = type && type . indexOf ( '.' ) !== - 1 ; // . ile başlıyorsa değişkene çevirmek için var details ; var isArrayTypeObject ; if ( isObject ) { type = varName + type ; } details = function ( num1 , num2 ) { var detail = '' ; if ( num1 >= 0 && num1 !== null && num2 && num2 !== null ) { detail = '(' + num1 + ',' + num2 + ')' ; // (5,2) } else if ( num1 >= 0 && num1 !== null ) { detail = '(' + num1 + ')' ; // (5) } return detail ; } ; if ( column . arrayDimension ( ) >= 1 ) { isArrayTypeObject = sequelizeTypes [ column . arrayType ( ) ] . type . indexOf ( '.' ) !== - 1 ; type += '(' ; if ( column . arrayDimension ( ) > 1 ) { type += new Array ( column . arrayDimension ( ) ) . join ( varName + '.ARRAY(' ) ; } // arrayDimension -1 tane 'ARRAY(' yaz type += isArrayTypeObject ? varName : "'" ; type += sequelizeTypes [ column . arrayType ( ) ] . type ; type += isArrayTypeObject ? '' : "'" ; } if ( enumValues ) { enumValues = util . inspect ( enumValues . substring ( 1 , enumValues . length - 1 ) . split ( ',' ) ) ; // Strip { and } -> make array -> makeJSON; enumValues = enumValues . substring ( 2 , enumValues . length - 2 ) ; // Strip '[ ' and ' ]' type += '(' + enumValues + ')' ; } if ( hasPrecision ) { type += details ( column . precision ( ) , column . scale ( ) ) ; } if ( hasLength ) { type += details ( column . length ( ) ) ; } if ( column . arrayDimension ( ) >= 1 ) { type += new Array ( column . arrayDimension ( ) + 1 ) . join ( ')' ) ; // arrayDimension -1 tane ) yaz } if ( ! isObject ) { type = "'" + type + "'" ; } return type ; }
Returns Sequelize ORM datatype for column.
@param {Object}      column                  - pg-structure column object.
@param {string}      [varName = DataTypes]   - Variable name to use in sequelize data type. ie. 'DataTypes' for DataTypes.INTEGER
@returns {string}
@private
@example
var typeA = column.sequelizeType();              // DataTypes.INTEGER(3)
var typeB = column.sequelizeType('Sequelize');   // Sequelize.INTEGER(3)
Returns Sequelize ORM datatype for column .