Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Hide Mongoose-specific properties behind common keyword #1171

Closed
christarnowski opened this Issue · 12 comments

4 participants

Krzysztof Tarnowski Aaron Heckmann rowan Gabriel Lesperance
Krzysztof Tarnowski

Mongoose Schema definitions reserve certain properties, such as options , schema, errors, on and isNew, for internal use. Instead, Mongoose should hide those properties behind common, non-colliding property, for example __mongoose__.

Related to #528.

Aaron Heckmann
Owner

schema, errors, on, isNew, are for public use. but yes, thanks for opening this so we can track this idea somewhere.

Krzysztof Tarnowski

@aheckmann How much work is required to address this issue? Maybe I could pitch-in (if it's on the roadmap, that is)?

Aaron Heckmann
Owner

nice! as long as we are only refactoring private stuff we can move forward with this change anytime.

Krzysztof Tarnowski

Awesome. I will try to nail it by the end of the next week.

Aaron Heckmann
Owner

relates to #1184

rowan

Any update on this? I'm running in to the issue with field names (eg. options) and want to know if it's worth me working around it, or if it's going to go away.

I'd be happy to help if you guys have decided on the best solution.

Krzysztof Tarnowski

@rowanu I'm a bit short on development time, so I can't make any promises. I will bump my priority on this one and hopefully I will be able to do some work during the upcoming weekend. Fingers crossed!

rowan

Thanks for the update! Let me know how it goes, and if I can help in any way.

rowan
Aaron Heckmann aheckmann referenced this issue from a commit
Aaron Heckmann aheckmann refactor; internal document properties
A schema path beginning with $ is invalid in mongodb, so
we know that no user will use this.

closes #1171
closes #1184
d6f1a2f
Aaron Heckmann aheckmann referenced this issue from a commit
Aaron Heckmann aheckmann refactor; internal document properties
A schema path beginning with $ is invalid in mongodb, so
we know that no user will use this.

closes #1171
closes #1184
2f593a6
Aaron Heckmann aheckmann referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Aaron Heckmann aheckmann referenced this issue from a commit
Aaron Heckmann aheckmann refactor; internal document properties
A schema path beginning with $ is invalid in mongodb, so
we know that no user will use this.

closes #1171
closes #1184
89cedc6
Aaron Heckmann aheckmann closed this issue from a commit
Aaron Heckmann aheckmann refactor; internal document properties
A schema path beginning with $ is invalid in mongodb, so
we know that no user will use this.

closes #1171
closes #1184
854abc8
Aaron Heckmann aheckmann closed this in 854abc8
Gabriel Lesperance

Is it normal that we still can't use "options" as a document property? I'm trying to create a model with the following schema but it fails...

var schema = new Schema({
    _id           : { type: ObjectId  , required: true,   index: true }

  , options       : { role              : { type      : String
                                          , required  : false
                                          , index     : true
                                          }

                    , position          : { type      : Number
                                          , required  : false
                                          , index     : true
                                          }
                    }
});

Any idea why?

The error I get is :

TypeError: Cannot read property 'getters' of undefined
    at model.Object.defineProperty.get [as options] (/Users/gabriel/Documents/wavo/workspace/wavo.me/node_modules/mongoose/lib/document.js:1106:24)
    at Function.compile (/Users/gabriel/Documents/wavo/workspace/wavo.me/node_modules/mongoose/lib/model.js:2125:34)
    at Mongoose.model (/Users/gabriel/Documents/wavo/workspace/wavo.me/node_modules/mongoose/lib/index.js:306:17)
Aaron Heckmann
Owner

Yes. options is currently disallowed since it is a publicly exposed (but not documented) property of a Model. We should hold off from allowing until v4 to be safe. Wanna open a ticket?

Gabriel Lesperance

I'll stick with mongoose 3.5.9 until version 4 is ready. The new ticket is #1416.

Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.