Remove undefined properties for create

See https://github.com/strongloop/loopback-connector-mongodb/issues/87
This commit is contained in:
Raymond Feng 2015-02-03 08:35:18 -08:00
parent 1f0f4b0f02
commit 9769df2c91
1 changed files with 2 additions and 1 deletions

View File

@ -231,7 +231,8 @@ DataAccessObject.create = function (data, callback) {
obj.trigger('save', function (saveDone) {
var _idName = idName(Model);
var modelName = Model.modelName;
this._adapter().create(modelName, this.constructor._forDB(obj.toObject(true)), function (err, id, rev) {
var val = removeUndefined(obj.toObject(true));
this._adapter().create(modelName, this.constructor._forDB(val), function (err, id, rev) {
if (id) {
obj.__data[_idName] = id;
defineReadonlyProp(obj, _idName, id);