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

ObjectId.prototype.valueOf() #7299

Closed
vkarpov15 opened this issue Dec 4, 2018 · 0 comments
Closed

ObjectId.prototype.valueOf() #7299

vkarpov15 opened this issue Dec 4, 2018 · 0 comments
Labels
backwards-breaking enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone

Comments

@vkarpov15
Copy link
Collaborator

Might be handy:

$ node
> const mongoose = require('mongoose')
undefined
> mongoose.Types.ObjectId.prototype.valueOf = function() { return this.toString() }
[Function]
> let id = new mongoose.Types.ObjectId()
undefined
> let id2 = new mongoose.Types.ObjectId(id.toString())
undefined
> id.valueOf()
'5c06e90e9f9d0a288edccbc6'
> id2.valueOf()
'5c06e90e9f9d0a288edccbc6'
> id === id2.toString()
false
> id == id2.toString()
true

Re: graphql/graphql-js#1518 (comment)

@vkarpov15 vkarpov15 added this to the Parking Lot milestone Dec 4, 2018
@vkarpov15 vkarpov15 added the enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature label Dec 4, 2018
sibelius added a commit to sibelius/mongoose that referenced this issue Dec 18, 2018
fix Automattic#7299
fix graphql/graphql-js#1518

this make interop of ObjectId and GraphQL easier
@vkarpov15 vkarpov15 modified the milestones: Parking Lot, 6.0 Mar 21, 2020
@vkarpov15 vkarpov15 reopened this Aug 3, 2021
@vkarpov15 vkarpov15 modified the milestones: 6.0.0-rc0, 6.0.0-rc1 Aug 11, 2021
vkarpov15 added a commit that referenced this issue Aug 11, 2021
…ing ObjectIds using double equals by default

Fix #7299
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards-breaking enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant