Skip to content

ObjectId.prototype.valueOf() #7299

@vkarpov15

Description

@vkarpov15

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    backwards-breakingenhancementThis issue is a user-facing general improvement that doesn't fix a bug or add a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions