lib/plugins/columnMapper.js
function (name, table, condition, opts) {
            opts = opts || {};
            if (name) {
                name = sql.stringToIdentifier(name);
                if (table && condition) {
                    opts = comb.merge({joinType: "left", table: table, condition: condition, column: name}, opts);
                    this._mappedColumns[name] = opts;
                } else {
                    throw new ModelError("mapped column requires a table and join condition");
                }
            }
            return this;
        }
function (name, table, condition, opts) {
            opts = opts || {};
            if (name) {
                name = sql.stringToIdentifier(name);
                if (table && condition) {
                    opts = comb.merge({joinType: "left", table: table, condition: condition, column: name}, opts);
                    this._mappedColumns[name] = opts;
                } else {
                    throw new ModelError("mapped column requires a table and join condition");
                }
            }
            return this;
        }
function ( name , table , condition , opts ) { opts = opts || { } ; if ( name ) { name = sql . stringToIdentifier ( name ) ; if ( table && condition ) { opts = comb . merge ( { joinType : "left" , table : table , condition : condition , column : name } , opts ) ; this . _mappedColumns [ name ] = opts ; } else { throw new ModelError ( "mapped column requires a table and join condition" ) ; } } return this ; }
Add a mapped column from another table. This is useful if there columns on
another table but you do not want to load the association every time.


For example assume we have an employee and works table. Well we might want the salary from the works table,
but do not want to add it to the employee table.

<b>NOTE:</b> mapped columns are READ ONLY.

{@code
patio.addModel("employee")
.oneToOne("works")
.mappedColumn("salary", "works", {employeeId : patio.sql.identifier("id")});
}

You can also change the name of the of the column

{@code
patio.addModel("employee")
.oneToOne("works")
.mappedColumn("mySalary", "works", {employeeId : patio.sql.identifier("id")}, {
column : "salary"
});
}

If you want to prevent the mapped columns from being reloaded after a save or update you can set the
<code>fetchMappedColumnsOnUpdate</code> or <code>fetchMappedColumnsOnSave</code> to false.

{@code

var Employee = patio.addModel("employee")
.oneToOne("works")
.mappedColumn("mySalary", "works", {employeeId : patio.sql.identifier("id")}, {
column : "salary"
});

//prevent the mapped columns from being fetched after a save.
Employee.fetchMappedColumnsOnSave = false;

//prevent the mapped columns from being re-fetched after an update.
Employee.fetchMappedColumnsOnUpdate = false;
}

You can also override prevent the properties from being reloaded by setting the <code>reload</code> or <code>reloadMapped</code> options when saving or updating.

{@code
//prevents entire model from being reloaded including mapped columns
employee.save(null, {reload : false});
employee.update(null, {reload : false});

//just prevents just the mapped columns from being reloaded
employee.save(null, {reloadMapped : false});
employee.update(null, {reloadMapped : false});
}

@param {String} name the name you want the column represented as on the model.
@param {String|patio.Model} table the table or model you want the property mapped from
@param condition the join condition. See {@link patio.Dataset#joinTable}.
@param {Object} [opts={}] additional options
@param {String} [opts.joinType="left"] the join type to use when gathering the properties.
@param {String|patio.sql.Identifer} [opts.column=null] the column on the remote table that should be used
as the local copy.

@return {patio.Model} returns the model for chaining.
Add a mapped column from another table . This is useful if there columns on another table but you do not want to load the association every time .