Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed Issue 298 - 'id' over-riding should mute the default virtual 'i…

…d' schema addition.
  • Loading branch information...
commit b4447725cca6bc74248f9e40d491a5d0b542039b 1 parent 038e2e8
@bnoguchi bnoguchi authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/mongoose/schema.js
View
4 lib/mongoose/schema.js
@@ -40,7 +40,7 @@ function Schema (obj, options) {
if (!this.paths['_id'])
this.add({ _id: {type: ObjectId, auto: true} });
- this.virtual('id').get(function () {
+ if (!this.paths['id']) this.virtual('id').get(function () {
return this._id.toString();
});
};
@@ -357,7 +357,7 @@ Schema.prototype.__defineGetter__('indexes', function () {
*/
Schema.prototype.virtual = function (name) {
- var virtuals = this.virtuals || (this.virtuals = {})
+ var virtuals = this.virtuals || (this.virtuals = {});
var parts = name.split('.');
return virtuals[name] = parts.reduce( function (mem, part, i) {
mem[part] || (mem[part] = (i === parts.length-1)
Please sign in to comment.
Something went wrong with that request. Please try again.