lib/index.js
function getHasManyName(hasMany) {
    var as, tableName;

    if (hasMany.through() !== undefined) {
        as = getBelongsToManyName(hasMany); //inflection.pluralize(getBelongsToName(hasMany.throughForeignKeyConstraint()));
    } else {
        as          = inflection.pluralize(hasMany.name());                  // cart_cart_line_items
        tableName   = hasMany.table().name();
        if (getSpecificConfig(tableName, 'generate.stripFirstTableFromHasMany')) {
            as = as.replace(new RegExp('^' + tableName + '[_-]?', 'i'), '');     // cart_cart_line_items -> cart_line_items
        }
        if (getSpecificConfig(tableName, 'generate.relationAccessorCamelCase')) {
            as = inflection.camelize(inflection.underscore(as), true);           // cart_line_items -> cartLineItems
        }
    }

    return as;
}
function getHasManyName(hasMany) {
    var as, tableName;

    if (hasMany.through() !== undefined) {
        as = getBelongsToManyName(hasMany); //inflection.pluralize(getBelongsToName(hasMany.throughForeignKeyConstraint()));
    } else {
        as          = inflection.pluralize(hasMany.name());                  // cart_cart_line_items
        tableName   = hasMany.table().name();
        if (getSpecificConfig(tableName, 'generate.stripFirstTableFromHasMany')) {
            as = as.replace(new RegExp('^' + tableName + '[_-]?', 'i'), '');     // cart_cart_line_items -> cart_line_items
        }
        if (getSpecificConfig(tableName, 'generate.relationAccessorCamelCase')) {
            as = inflection.camelize(inflection.underscore(as), true);           // cart_line_items -> cartLineItems
        }
    }

    return as;
}
function getHasManyName ( hasMany ) { var as , tableName ; if ( hasMany . through ( ) !== undefined ) { as = getBelongsToManyName ( hasMany ) ; //inflection.pluralize(getBelongsToName(hasMany.throughForeignKeyConstraint())); } else { as = inflection . pluralize ( hasMany . name ( ) ) ; // cart_cart_line_items tableName = hasMany . table ( ) . name ( ) ; if ( getSpecificConfig ( tableName , 'generate.stripFirstTableFromHasMany' ) ) { as = as . replace ( new RegExp ( '^' + tableName + '[_-]?' , 'i' ) , '' ) ; // cart_cart_line_items -> cart_line_items } if ( getSpecificConfig ( tableName , 'generate.relationAccessorCamelCase' ) ) { as = inflection . camelize ( inflection . underscore ( as ) , true ) ; // cart_line_items -> cartLineItems } } return as ; }
Calculates hasMany relation name based on table, column and config.
@private
@param {object} hasMany - pg-structure foreign key constraint object.
@returns {string} - Name for the belongsTo relationship.
Calculates hasMany relation name based on table column and config .