Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed; setting nested objects directly now works properly

  • Loading branch information...
commit 485e1f6e1fccabb42ef154379d0806f33509a3d6 1 parent 3d7646a
@aheckmann aheckmann authored
Showing with 24 additions and 17 deletions.
  1. +24 −17 lib/mongoose/document.js
View
41 lib/mongoose/document.js
@@ -432,29 +432,36 @@ function define (prop, subprops, prototype, prefix) {
, path = (prefix ? prefix + '.' : '') + prop;
if (subprops) {
- // if prop hasn't been defined
- prototype.__defineGetter__(prop, function () {
- if (!this.__getters)
- this.__getters = {};
-
- if (!this.__getters[path]) {
- var nested = function(){};
- nested.prototype.__proto__ = this;
- nested.prototype.toObject = function () {
- return this.get(path);
- };
- compile(subprops, nested.prototype, path);
- this.__getters[path] = new nested();
- }
- return this.__getters[path];
+ Object.defineProperty(prototype, prop, {
+ enumerable: true
+ , get: function ( ) {
+ if (!this.__getters)
+ this.__getters = {};
+
+ if (!this.__getters[path]) {
+ var nested = function(){};
+ nested.prototype.__proto__ = this;
+ nested.prototype.toObject = function () {
+ return this.get(path);
+ };
+ compile(subprops, nested.prototype, path);
+ this.__getters[path] = new nested();
+ }
+
+ return this.__getters[path];
+ }
+ , set: function (v) {
+ return this.set(v, path);
+ }
});
+
} else {
Object.defineProperty(prototype, prop, {
- get: function ( ) { return this.get(path); }
+ enumerable: true
+ , get: function ( ) { return this.get(path); }
, set: function (v) { return this.set(path, v); }
- , enumerable: true
});
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.