Dynamic schema keys in Mongoose
<p>I have a simple requirement to get dynamic keys and their values to insert in mongo.</p>

<p>something like this:</p>

<pre><code>[
  {"key1": "val1"},
  {"key2": "val2"}
]
</code></pre>

<p>For this I have created schema as :
As I read about <code>[Schema.Types.Mixed]</code>,but it only makes datatype of assigned values dynamic ,not the key in my case.</p>

<pre><code>var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var myschema = new Schema({ key: [Schema.Types.Mixed] });

module.exports = mongoose.model('DataCollection', myschema);
</code></pre>

<p>Can anybody point , whtat is it that I am missing.
This is my output,which shows blank value.</p>

<p>Thanks in advance.</p>

<p><a href="https://i.stack.imgur.com/79eD3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/79eD3.png" alt="enter image description here"></a></p>