title: How to save a document that has a reference of an array in mongoose nodejs
body: <p>Help, I want to be able to post several items into the array,, I have two models control and subcontrol is referenced in the control model as an array.</p>
  <p>My post api for the control:</p>
  <pre><code>router.post(
    '/add',
    auth,
    role.checkRole(role.ROLES.Admin, role.ROLES.Regulator),
    async (req, res) =&gt; {
      try {
  
  
      const subControl = new SubControl({...req.body}); 
      const subControlDoc = await subControl.save();
      const control = new Control({...req.body, subControl: subControlDoc._id}); 
      const savedControl = await control.save();
  
        res.status(200).json({
          success: true,
          message: `Control has been added successfully!`,
          control: savedControl
        });
      } catch (error) {
        return res.status(400).json({
          error
          // error: 'Your request could not be processed. Please try again.'
        });
      }
    }
  );
  </code></pre>
  <p>My postman:</p>
  <pre><code>{
     &quot;mainControl&quot;: &quot;1-3&quot;,
     &quot;subControl&quot;: 
     [
     {
      &quot;subControlNo&quot;: &quot;1-3-1&quot;
     },
      {
      &quot;subControlNo&quot;: &quot;1-3-2&quot;
     }
     ],
    &quot;description&quot;: &quot;controldescription&quot;,
    &quot;controlStatus&quot;: &quot;Started&quot;,
    &quot;mControlProgress&quot;: &quot;Implemented&quot;,
    &quot;sControlProgress&quot;: &quot;Implemented&quot;,
    &quot;comments&quot;: &quot;ffffffffffffff&quot;,
    &quot;actionOwner&quot;: &quot;ROLE_ADMIN&quot;,
    &quot;missingFiles&quot;: &quot;file1 and file2&quot;,
    &quot;recommendations&quot;: &quot;revise control1 and 2&quot;
    }
  </code></pre>
  <p>Response:</p>
  <pre><code>{
      &quot;success&quot;: true,
      &quot;message&quot;: &quot;Control has been added successfully!&quot;,
      &quot;control&quot;: {
          &quot;_id&quot;: &quot;621c9d2696f73d0ad39a0d12&quot;,
          &quot;subControl&quot;: [
              &quot;621c9d2696f73d0ad39a0d11&quot;
          ],
          &quot;controlStatus&quot;: &quot;Started&quot;,
          &quot;mControlProgress&quot;: &quot;Implemented&quot;,
          &quot;sControlProgress&quot;: &quot;Implemented&quot;,
          &quot;actionOwner&quot;: &quot;ROLE_ADMIN&quot;,
          &quot;mainControl&quot;: &quot;1-3&quot;,
          &quot;comments&quot;: &quot;ffffffffffffff&quot;,
          &quot;missingFiles&quot;: &quot;file1 and file2&quot;,
          &quot;recommendations&quot;: &quot;revise control1 and 2&quot;,
          &quot;created&quot;: &quot;2022-02-28T10:00:06.982Z&quot;,
          &quot;__v&quot;: 0
      }
  }
  </code></pre>
  <p>I want to add several subcontrols into the control model. Plus if anyone recommends a book or the best way to learn nodejs and mongodb because I'm having some difficulties in finding resources.</p>