diff --git a/lib/dbwrap.js b/lib/dbwrap.js index 520d722..c7ab8da 100644 --- a/lib/dbwrap.js +++ b/lib/dbwrap.js @@ -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' };