From 3a0f0d4d5d268fda620c24e7844c9a9d069edca8 Mon Sep 17 00:00:00 2001 From: Sibelius Seraphini Date: Tue, 18 Dec 2018 11:02:27 -0200 Subject: [PATCH] feat(objectid): add valueOf to ObjectId prototype fix #7299 fix graphql/graphql-js#1518 this make interop of ObjectId and GraphQL easier --- lib/types/objectid.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/types/objectid.js b/lib/types/objectid.js index cbe9bd8b06a..692799e0994 100644 --- a/lib/types/objectid.js +++ b/lib/types/objectid.js @@ -24,4 +24,8 @@ Object.defineProperty(ObjectId.prototype, '_id', { } }); +ObjectId.prototype.valueOf = function() { + return this.toString(); +}; + module.exports = ObjectId;