title: How do I set values in a nested map in mongoose directly
body: <p>I have a mongoose schema which has a map(holding) nested in other map(users).</p>
  <pre><code>const UserSchema = new mongoose.Schema({
    users: {
      type: Map,
      of: new mongoose.Schema({
        holding: {
          type: Map,
          of: Number,
        },
      }),
    },
  });
  const UserModel = mongoose.model('black', UserSchema);
  </code></pre>
  <p>I create a new user with the below info.</p>
  <pre><code>  var user = new userModel({
      users: {
        jose: {
          holding: { itc: 9, hcl: 300 },
        },
      },
    });
  </code></pre>
  <p>Now I am trying to edit a value in the map <code>holdings</code> for my user with the set method. Which I am able to do as below.</p>
  <pre><code>  await user.set(`users.jose`, {
      holding: { itc: 90, hcl: 300 },
    });
    user.get(`users.jose.holding.itc`) //displays new value(90)
  </code></pre>
  <p>However  if I try to set the values in nested map &quot;holding&quot; directly this does not work.</p>
  <p>ie the below code fails(value is not set)</p>
  <pre><code>await user.set(`users.jose.holding.itc`, 1000);
  user.get(`users.jose.holding.itc`) //gives old value or does not display 1000
  </code></pre>
  <p>Why does this fail? .How do I set values in a nested map in mongoose directly.</p>