patternMinor
MongoDB Shell support for map.set()
Viewed 0 times
mapmongodbshellforsetsupport
Problem
I am trying to use the MongoDB shell to run some scripts. Inside the JavaScript I am attempting to run
However, I am getting the following error:
I am running this
Does the
var map = new Map() then map.set(1,1).However, I am getting the following error:
E QUERY [js] TypeError: map.set is not a function :I am running this
mongo shell version: MongoDB shell version v4.2.1Does the
mongo shell not support the map.set() function?Solution
No, they hide the standard implementation in implscope.cpp
// This builtin map is a javascript 6 thing. We want our version. so
// take theirs out
and implement a new one in types.js.
Well, you can workaround doing:
// This builtin map is a javascript 6 thing. We want our version. so
// take theirs out
and implement a new one in types.js.
Well, you can workaround doing:
Map.prototype.set = Map.prototype.putCode Snippets
Map.prototype.set = Map.prototype.putContext
StackExchange Database Administrators Q#253561, answer score: 2
Revisions (0)
No revisions yet.