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

Already on GitHub? Sign in to your account

.lean() - "lean" ObjectIds to strings too? #1955

mihai-chiorean opened this Issue Mar 11, 2014 · 6 comments


None yet
4 participants

mihai-chiorean commented Mar 11, 2014

how about making .lean() turn objectids as strings?

I often find myself making operations with arrays of ids. Some basic JS array operations don't work if the array contains ObjectIds. Also, I RARELY find myself actually making use of the properties of an ObjectId.


vkarpov15 commented Mar 5, 2015

Not likely to be in mongoose core anytime soon, because ObjectIds aren't actually strings, they're just conveniently represented as strings. However, easy to make a plugin for this :)

@vkarpov15 vkarpov15 added the plugin label Mar 5, 2015


mihai-chiorean commented Mar 5, 2015

challenge accepted :)


vkarpov15 commented Mar 6, 2015

I can't tell you how much headache this has caused me. Please reconsider.

Can you also tell me what else .lean() doesn't do?

nasr18 commented Apr 29, 2016

if you want to work on mongoose returned object, then dont use lean(). and really this caused me also a great trouble.


vkarpov15 commented Apr 29, 2016

@brandonros what exactly are you trying to do?

lean() bypasses all mongoose-specific stuff so the value returned from the query is the same as it would be if you used the mongodb driver directly without going through mongoose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment