ignore some relationship fields on save

This commit is contained in:
AJ ONeal 2015-10-21 07:31:18 +00:00
parent 69e5f9eda8
commit fdb142ecbf
1 changed files with 20 additions and 0 deletions

View File

@ -240,6 +240,26 @@ function wrap(db, dir) {
var sql;
var vals = [];
['hasOne', 'hasMany', 'hasAndBelongsToMany', 'belongsTo', 'belongsToMany'].forEach(function (relname) {
var rels = opts[relname];
if (!rels) {
return;
}
if (!Array.isArray(rels)) {
rels = [rels];
}
// don't save relationships
rels.forEach(function (colname) {
delete data[colname];
delete data[camelCase(colname)];
// TODO placehold relationships on find / get?
// data[camelCase(colname)] = null;
});
});
(opts.indices || []).forEach(function (col) {
if ('string' === typeof col) {
col = { name: col, type: 'TEXT' };