How to use for loop in mongoose find function?

Here is my code:'/update', async (req, res, done) => {
  let drive ='drive');
  let fileId =;
  let subject = req.body.subject;
  let grade = req.body.grade;
  let industry = req.body.industry;
  await TagFile.findOne({id: fileId}, (err, res) => {
    if (err) return console.log(err);
  function takeRes(res) {
    for (let i = 0; i > subject.length; i++) {
      if(!res[0].subject.includes(subject[i])) {
        console.log("first was called")
      else {
        console.log("else was called.")

This is a post request that is made from my site. When it gets to the step where the for loop needs to be used, I don’t get anything in the console from the if else statements. I know this probably has something to do with async, but I don’t fully understand it, and would love a push in the right direction. Thank you!

221 thoughts on “How to use for loop in mongoose find function?”

  1. Pingback: zovirax florek
  2. Pingback: viagra prices
  3. Pingback: viagra generic
  4. Pingback: viagra sale
  5. I loved as much as you will receive carried out right here.
    The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an impatience over that you
    wish be delivering the following. unwell unquestionably come
    further formerly again as exactly the same nearly a lot often inside
    case you shield this increase.

  6. Pingback: cialis pills
  7. Pingback: what is tadalafil
  8. Pingback: viagra coupon
  9. Pingback: cialis 2 mg
  10. Pingback: cost viagra
  11. Pingback: natural viagra
  12. Pingback: hims viagra
  13. Pingback: viagra cvs
  14. Pingback: walmart viagra
  15. Pingback: levitra
  16. Pingback: compra viagra
  17. Pingback: sildenafil viagra
  18. Pingback: roman sildenafil
  19. Pingback: sildenafil revatio
  20. Pingback: hims sildenafil
  21. Pingback: sildenafil teva
  22. Pingback: viagra substitute
  23. Pingback: teva sildenafil

Leave a Comment