Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-2378 enable getters for properties defined with non-strict schemas; u... #2439

Merged
merged 1 commit into from
Nov 5, 2014

Conversation

alabid
Copy link
Contributor

@alabid alabid commented Nov 4, 2014

See #2378 for more details. The tests in test/document.strict.test.js have been appropriately updated as well.
All tests (including new assert's pass.

@vkarpov15
Copy link
Collaborator

Well done.

vkarpov15 added a commit that referenced this pull request Nov 5, 2014
gh-2378 enable getters for properties defined with non-strict schemas; u...
@vkarpov15 vkarpov15 merged commit 4f92674 into Automattic:master Nov 5, 2014
@laggingreflex
Copy link

Is this solved, or pushed to npm? I'm using 3.8.23 and the issue is still present

Just checked, the changes in this PR's commit aren't in my /lib/document.js

PS: Even not in https://github.com/Automattic/mongoose/blob/3.8.x/lib/document.js#L62

@laggingreflex
Copy link

Also just found out that this doesn't solve all cases. Only values that are defined work. Any new properties created are still ignored.

var User = mongoose.model('users', new mongoose.Schema(
    {username: String} , {strict: false}
));

var user = new User({a: 'a'}); //=> a is defined

user.a = 'b'; //-> a was defined 
console.debug(user.get('a')); //=> 'b' (ok)

user.c = 'c'; //-> c was not defined
console.debug(user.get('c')); //=> undefined (not ok!)

:(. Not even sure if this is even implementable (maybe with proxy in ES6). Although would be perfect for a truly schema-less document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants