The title is not very clear, I'll demonstrate what I mean.
I have a document that looks something like the following...
const room_schema = new Schema({
  room_id: data.room_id,
  song_queue: [{
    _id: false,
    user_id: String,
  }],
});
The song_queue is an array. In my code I have a variable that gives me the index of the element I need to update. Let's call the variable position...
room = await Room.findOneAndUpdate(
  { 
    room_id: data.room_id 
  },
  {
    "song_queue." + position + ".user_id": data.user_id
  }
);
I need to use that variable within the key, however, the code above does not work. How can I make my logic work?
 
    