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

after document.toJSON() id is not string #3647

Closed
davibe opened this issue Dec 4, 2015 · 3 comments
Closed

after document.toJSON() id is not string #3647

davibe opened this issue Dec 4, 2015 · 3 comments
Labels
can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.

Comments

@davibe
Copy link

davibe commented Dec 4, 2015

even if document.toJSON().id looks like a string its type is object and i always have t convert it by doing + "" if i want a proper string. Why is that ?

@vkarpov15
Copy link
Collaborator

That's unexpected, can you show me a more complete code sample? The below script:

var assert = require('assert');
var mongoose = require('mongoose');

mongoose.connect('mongodb://localhost:27017/gh3647');
mongoose.set('debug', true);

var schema = new mongoose.Schema({ name: String });
schema.set('toJSON', { virtuals: true });

var Person = mongoose.model('Person', schema);

var person = new Person({ name: 'Val' });

console.log(typeof person.toJSON().id);
console.log(person.toJSON().id);

gives me the expected output

$ node gh-3647.js 
string
5661da6e68dc09442b70bcd0

@vkarpov15 vkarpov15 added this to the 4.2.10 milestone Dec 4, 2015
@vkarpov15 vkarpov15 added the can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity. label Dec 4, 2015
@davibe
Copy link
Author

davibe commented Dec 5, 2015

We are using 4.1.9. Will check again, thank you.

@vkarpov15 vkarpov15 modified the milestones: 4.3.1, 4.2.10 Dec 9, 2015
@vkarpov15 vkarpov15 modified the milestones: 4.3.3, 4.3.2 Dec 17, 2015
@vkarpov15
Copy link
Collaborator

Issue's gone stale, re-open if this is still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.
Projects
None yet
Development

No branches or pull requests

2 participants