title: how to save multiple for loops data?
body: <p>In Post request, I want to pull objectId's data and save it in the database. There will be 2 or 3 objectId's which will I will be getting it in array. From that array I am able to pull the data with separate "for loops" but at the end I am not able to save the data. 
  I want to know how to move data from one array to another or directly save the data.</p>
  
  <p>Schema:--</p>
  
  <pre><code>const jobSch = new Schema({
      token : {type:Number},
      name : {type:String},
      phoneNumber: {type:Number},
      gender : {type:String},
      stage : {type:String},
      categoryId : [Schema.Types.ObjectId],
      subCategoryId : [Schema.Types.ObjectId],
      serviceId : [Schema.Types.ObjectId],
      category : [String],
      subcategory : [String],
      service: [String],
      paymenttype: [String],
      tax: {type:Number},
      totalprice: {type:String},
      servicePerson: {type:String},
      createdOn : {type:Date, default:new Date()},
      updatedOn : {type:Date, default:new Date()}   
  });
  </code></pre>
  
  <p>POST request code:--</p>
  
  <pre><code>router.post('/', async (req, res) =&gt; {
      let ids = req.body;
      let catId = ids.categoryId;
      console.log("catId", catId)
      console.log("catId.length", catId.length)
      let subcatId = ids.subCategoryId;
      console.log("subcatId", subcatId);
      console.log("subcatId.length", subcatId.length)
      let serId = ids.serviceId;
      console.log("serId", serId);
      console.log("subcatId.length", serId.length)
      let job = new Job(ids);
      let catgy=[];
      let subcatgy=[];
      let subser=[];
  
      for (i = 0; i &lt; catId.length; i++) {
          Category.findById(catId[i])
              .then(category =&gt; {
                  if (category &amp;&amp; category != null) {
                      console.log('category.name', category.name);
                      catgy.push(`${category.name}`)
                      console.log(catgy);
  
                  }
              })
      }
      for (i = 0; i &lt; subcatId.length; i++) {
          Service.findById(subcatId[i])
              .then(service =&gt; {
                  if (service &amp;&amp; service != null) {
                      console.log('service.name', service.name);
                      subcatgy.push(`${service.name}`)
                      console.log(subcatgy);
  
                  }
              })
      }
      for (i = 0; i &lt; serId.length; i++) {
          Subservice.findById(serId[i])
              .then(subService =&gt; {
                  if (subService &amp;&amp; subService != null) {
                      console.log('subservice.name', subService.subService);
                      subser.push(`${subService.subService}`)
                    console.log(subser);
                  }
              })
      }
      var category = catgy.slice();
      console.log("category1", category)
      var service = subcatgy.slice();
      console.log('service2', service);
      var subService = subser.slice();
      console.log('subService3',subService);
      console.log(job);
      job.save().then(job =&gt; {
          res.status(201).json({
              message: 'Job saved successfully', job
          })
      }).catch(err =&gt; console.log(err));
  });
  </code></pre>