lib/relations/base.js
function(baseTable, joinTable) {
    var jk = [baseTable, this.joinKeyAttr].join('.');
    var ik = [joinTable, this.inverseKeyAttr].join('.');
    var parts = [jk, ik];

    // for readability, we like to keep the foreign key first in the join
    // condition, so if the join key is the primary key, swap the order of the
    // condition.
    if (this.joinKey === this.primaryKey) {
      parts.reverse();
    }

    return parts.join('=');
  }
function(baseTable, joinTable) {
    var jk = [baseTable, this.joinKeyAttr].join('.');
    var ik = [joinTable, this.inverseKeyAttr].join('.');
    var parts = [jk, ik];

    // for readability, we like to keep the foreign key first in the join
    // condition, so if the join key is the primary key, swap the order of the
    // condition.
    if (this.joinKey === this.primaryKey) {
      parts.reverse();
    }

    return parts.join('=');
  }
function ( baseTable , joinTable ) { var jk = [ baseTable , this . joinKeyAttr ] . join ( '.' ) ; var ik = [ joinTable , this . inverseKeyAttr ] . join ( '.' ) ; var parts = [ jk , ik ] ; // for readability, we like to keep the foreign key first in the join // condition, so if the join key is the primary key, swap the order of the // condition. if ( this . joinKey === this . primaryKey ) { parts . reverse ( ) ; } return parts . join ( '=' ) ; }
Join support for a relation.

This method joins a table, `baseTable` to `joinTable` using
{@link BaseRelation#joinKey} as the attribute on the `baseTable` and
{@link BaseRelation#inverseKey} as the attribute on `joinTable`.

It also ensures that the foreign key will come first in the resulting
condition (for readability, it's generally a little more understandable to
see the foreign key first).

@method
@protected
@param {String} baseTable The table name/alias of the existing table.
@param {String} relatedTable The table name/alias being joined.
@return {String} A string that represents the appropriate join condition.
Join support for a relation .