title: Best way to store table (spreadsheet) data in mongodb
body: <p>To store table like data in Mongodb when the table is fixed size, arrays could work. But when the table can grow (like a spreadsheet) or even be more flexible (the number animals of a species at a zoo, where both the species and zoo can be extended) this won't work. So I'm thinking more like:</p>
  
  <pre><code>{
      "name": "spreadsheet example",
      "cells": [
          {
              "row": 1,
              "col": 1,
              "val": 4
          },
          {
              "row": 1,
              "col": 2,
              "val": 9
          },
          {
              "row": 1,
              "col": 3,
              "val": "a1+a2"
          }
      ]
  }
  </code></pre>
  
  <p>This would work, and even be efficient for sparse table, but when rendering the table to HTML it would require a lookup for every cell, or building some intermediate data structure. Also, this way a single cell can be updated using the '$' positional operator in an update, but if we have multiple tabs there is a problem as the '$' cannot be nested...</p>
  
  <p>Is there a better way to store this information in mongodb? I considerd using the row/col names as field names, but that results in dynamic field names, also probably not the best solution.</p>