-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
I want to auto convert ObjectId to string #6996
Comments
GraphQL have used a new method to serialize ID, the new method doesn't support ID in object type anymore, but following codes will help on this: const mongoose = require('mongoose');
const ObjectId = mongoose.Types.ObjectId;
ObjectId.prototype.valueOf = function () {
return this.toString();
}; Hope mongoose will support this feature soon :) |
Interesting idea @Lanfei , will investigate that for a future release. |
@vkarpov15 Nice, thanks :) |
Hi any news about this? |
@vkarpov15, definitely, great idea, waiting for 5.4 patiently. |
5.4.0 is out, here's the workaround |
Do you want to request a feature or report a bug?
What is the current behavior?
I use with Apollo server 2.0. when I want _id, but in response data, ObjectId is not converted to String.
What is the expected behavior?
How to auto convert ObjectId to String?
Please mention your node.js, mongoose and MongoDB version.
"mongoose": "^5.2.13",
node: 8
MongoDB: 3.6
The text was updated successfully, but these errors were encountered: