Answer the question
In order to leave comments, you need to log in
How to store a 2D array in MongoDB?
Good evening! I am learning Node.JS in conjunction with MongoDB. To interact with the database, I use the mongoose framework. There is this code:
db = mongoose.connect ( 'mongodb://localhost/test' );
var ServerSchema = mongoose.Schema ( { key: String, users: Number, size: Number, map: Array } );
var Server = mongoose.model ( 'Server', serverSchema );
Server.findOne( { key: key }, 'users map', function ( err, serv ) {
if ( err ) return console.error ( err );
console.log ( serv.map );
});
map
returned one-dimensional. How to implement saving?
Answer the question
In order to leave comments, you need to log in
Array is a one-dimensional array. A two-dimensional array is an Array that stores Arrays.
Generally speaking, there are no two-dimensional arrays in js.
Try the native driver first and play around with different collection options.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question