Increment matrix structure in MongoDb
I would like to have a matrix structure (a NxN integer matrix) and I want to increment values in it. Which is the right approach to model a matrix in MongoDb and to increment theirValues? Andrew Orsich Lets consider we have: 1 2 3 4 5 6 7 8 9 You can store matrix as embedded array in mongodb in different ways: 1.Represent matrix as one-dimensional array and store like this: { _id: "1", matrix: [1,2,3,4,5,6,7,8,9], width: 3, // or store just size in case of NxN height: 3, } Then to increment third element of matrix you will need following update: db.matrix.update({_id: 1}, { $inc : { "matrix.2"