title: How to name the index of a mongo json array
body: <p>I'm trying to write a document in mongo with a string instead of a number in the index of the array, but I'm not succeeding. Is it possible to do that?</p>
  
  <p>Example:</p>
  
  <p>This is a simple array declared in json in javascript:</p>
  
  <pre><code>var models = {
  
      'Casa1A': {
  
          'X': 6,
          'Y': 4,
          'Image': 'house1A'
  
      }
  
  };
  </code></pre>
  
  <p>I can use it like this:</p>
  
  <pre><code>alert(models['Casa1A'].x);
  </code></pre>
  
  <p>I'd like to do the same in a mongo collection, but I'm not getting it.</p>
  
  <pre><code>var modelModels = new mongoose.Schema ({
      
          X: Number,
          Y: Number,
          Image: String
     
  });
  exports.models = mongoose.model('models', modelModels);
  </code></pre>
  
  <p>But to use I have to do with numbers:</p>
  
  <pre><code>alert(models[0].x);
  </code></pre>
  
  <p>How do I use <code>models['casa1A']</code>?</p>