title: Save only specified field in mongoDB from array of objects
body: <p>I want to save only the path field of uploaded documents data.</p>
  <p>The function to save the data:</p>
  <pre><code>exports.uploadDocuments = async (_id, file) =&gt; {
    console.log(Object.values(file.profile_picture));
    if (file.profile_picture) {
      document = await User.findByIdAndUpdate(
        { _id },
        { $set: { profile_picture: Object.values(file.profile_picture) } }
      );
    }
    if (file.documents) {
      document = await User.findByIdAndUpdate(
        { _id },
        {
          $set: { registration_process_value: 99 },
          $push: { documents: { $each: file.documents } },
        },
        { new: true }
      );
    }
    return document;
  };
  </code></pre>
  <p>I want to save only profile picture's path but documents I need is full document.
  How can I save only path field of the document.</p>
  <p>The result after I log the files:</p>
  <pre><code>[
    {
      fieldname: 'profile_picture',
      originalname: 'Active Drivers.png',
      encoding: '7bit',
      mimetype: 'image/png',
      destination: 'src/uploads/',
      filename: 'profile_picture-1661167606845.png',
      path: 'src\\uploads\\profile_picture-1661167606845.png',
      size: 47922
    }
  ]
  </code></pre>