lib/index.js
function getBelongsToName(fkc) {
    var as          = fkc.foreignKey(0).name(),                                             // company_id
        tableName   = fkc.table().name(),
        camelCase   = getSpecificConfig(tableName, 'generate.relationAccessorCamelCase'),
        prefix      = getSpecificConfig(tableName, 'generate.prefixForBelongsTo');          // related

    if (as.match(/_id$/i)) {
        as = as.replace(/_id$/i, '');                                                       // company_id -> company
    } else {
        as = prefix + '_' + as;                                                             // company -> related_company
    }
    if (camelCase) {
        as = inflection.camelize(inflection.underscore(as), true);
    }
    return inflection.singularize(as);
}
function getBelongsToName(fkc) {
    var as          = fkc.foreignKey(0).name(),                                             // company_id
        tableName   = fkc.table().name(),
        camelCase   = getSpecificConfig(tableName, 'generate.relationAccessorCamelCase'),
        prefix      = getSpecificConfig(tableName, 'generate.prefixForBelongsTo');          // related

    if (as.match(/_id$/i)) {
        as = as.replace(/_id$/i, '');                                                       // company_id -> company
    } else {
        as = prefix + '_' + as;                                                             // company -> related_company
    }
    if (camelCase) {
        as = inflection.camelize(inflection.underscore(as), true);
    }
    return inflection.singularize(as);
}
function getBelongsToName ( fkc ) { var as = fkc . foreignKey ( 0 ) . name ( ) , // company_id tableName = fkc . table ( ) . name ( ) , camelCase = getSpecificConfig ( tableName , 'generate.relationAccessorCamelCase' ) , prefix = getSpecificConfig ( tableName , 'generate.prefixForBelongsTo' ) ; // related if ( as . match ( / _id$ / i ) ) { as = as . replace ( / _id$ / i , '' ) ; // company_id -> company } else { as = prefix + '_' + as ; // company -> related_company } if ( camelCase ) { as = inflection . camelize ( inflection . underscore ( as ) , true ) ; } return inflection . singularize ( as ) ; }
Calculates belongsTo relation name based on table, column and config.
@private
@param {object} fkc - pg-structure foreign key constraint object.
@returns {string} - Name for the belongsTo relationship.
Calculates belongsTo relation name based on table column and config .