Does MongoDB support Map objects?

Viewed 8891

Suppose I have a Map of ordered items in a node.js application:

var myMap = new Map();
myMap.set("a", "b");
myMap.set("c", "d");
myMap.set("e", "f");

I then store this map in a database using the MongoDB node.js driver:

collection.insertOne({myMap: myMap});

The stored map looks like:

{ "myMap" : { "a" : "b", "c" : "d", "e" : "f" } }

I know that a Map's order is guaranteed, but is it guaranteed to be stored in MongoDB in that order? And is it guaranteed to be read from MongoDB in that order?

It's a pretty simple question, but I couldn't find anything in the MongoDB documentation about it supporting Maps.

1 Answers
Related