Q:

Mongoose finding and updating single subdocument in node.js

I have a Schema like this,
const UserSchema = new Schema(
  {
    name: {
      type: String,
      required: true
    },
    payment:[{
      description: {
        type:String
      },
      amount:{
        type:String
      },
      paid:{
        type:Boolean,
        default:false
      }
    }]
  },
  { timestamps: true }
);

so here in payment sub document I have multiple entry. How can i find and change one single document of this sub doc by id. is there any functionality User.payment.findbyID() exists? please help me out. I  I want to update User.payment.paid==true for one doc .I am useing express.js
I have made a stupid attempt that didnt make sense while i was trying:
exports.ConfirmPayment= async(req,res)=>{
  let payment
  try{
    payment= await User.findById(req.params.id).payment
    ConfirmPayment = await payment.findById(req.params.paymentId)
    ConfirmPayment.paid==true
    await ConfirmPayment.save()
    await payment.save()
    res.status(200).json(ConfirmPayment)
  }catch(err) {
    console.log(err)
  }

};

A:

I found the solution. I tried filtering query and it worked. Here is my solution:
    const paymentDB = user.payment.filter( (payment)=> {
      return payment.amount === req.params.amount;
    }).pop();
    paymentDB.paid=true;
    await user.save()

