title: How to change boolean value within an object of a document sub-array in Mongoose?
body: <p>I have a rooms model. Within it is an array of User's which has its own model.</p>
  
  <p>Each user has a bunch of different attributes, some of them being boolean. Knowing the ID of the specific room and the specific user, I am attempting to change the boolean value within a specific User element within the sub array like this:</p>
  
  <pre><code>Room.findOne({_id: roomId, "users" : user}, { "$set" : { mutedAudio : false}})
          .then(doc =&gt; {
              console.log("Unmuted audio");
              res.json(doc)
              io.in(roomId).emit('userchange');
          })
          .catch(err =&gt; {
              console.log(err);
          })
  </code></pre>
  
  <p>(I'm using a user model instead of a user ID for seeking the user within the sub array. Could not get ID to work but can fetch object by comparing it to itself entirely.)</p>
  
  <p>I get the error:</p>
  
  <pre><code>MongoError: Unsupported projection option: $set: { mutedAudio: true }
  </code></pre>
  
  <p>Anyone know the answer to this? </p>
  
  <p>Thank you.</p>
  
  <p>EDIT:</p>
  
  <pre><code>const RoomSchema = new Schema({
      owner: {
          id: {
              type: String
          },
          username: {
              type: String
          }
      },
      roomname: {
          type: String,
          required: true
      },
      category: {
          type: String,
          required: true
      },
      password: {
          type: String,
          required: false
      },
      users: [UserSchema],
      messages: [{
          username: {
              type: String
          },
          message: {
              type: String
          },
          time: {
              type: String
          }
      }],
      date: {
          type: Date,
          default: Date.now
      }
  });
  
  const UserSchema = new Schema({
      id: {
          type: String
      },
      username: {
          type: String,
          required: true
      },
      email: {
          type: String,
          required: true
      },
      password: {
          type: String,
          required: true
      },
      avatar: {
          type: String
      },
      date: {
          type: Date,
          default: Date.now
      },
      micEnabled: {
          type: Boolean,
          default: false
      },
      mutedAudio: {
          type: Boolean,
          default: true
      }
  });
  </code></pre>