Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
use Object.assign() where a clone needed
Browse files Browse the repository at this point in the history
  • Loading branch information
vdemedes committed Feb 21, 2016
1 parent a09fa0b commit 12c7e81
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/mongorito.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const mongodb = require('mongodb');
const Promise = require('bluebird');
const extend = require('class-extend').extend;
const result = require('lodash.result');
const assign = require('object-assign');
const clone = require('clone');
const get = require('get-value');
const set = require('set-value');
Expand Down Expand Up @@ -138,10 +139,10 @@ Mongorito._collections = {};
*/

function Model (attrs, options) {
this.attributes = clone(attrs || {});
this.attributes = assign({}, attrs);
this.changed = {};
this.previous = {};
this.options = clone(options || {});
this.options = options || {};

// reset hooks
Object.defineProperty(this, '_hooks', {
Expand Down Expand Up @@ -303,7 +304,7 @@ Model.prototype._setDefaults = function () {
*/

Model.prototype.toJSON = function () {
return this.attributes;
return assign({}, this.attributes);
};


Expand Down

0 comments on commit 12c7e81

Please sign in to comment.