title: MongoDB + Express How to Optimize the code?
body: <p>Hello everybody i have this bad code for me how i can optimize it ?</p>
  
  <p>If i used SQL i can do used inner Queries in one query...</p>
  
  <p>"User" it's only object from mongoose</p>
  
  <pre><code>  getProfile: async (req, res) =&gt; {
          const { id } = req.params;
  
          try {
              const {
                  image,
                  name,
                  gender,
                  about,
                  email,
                  phone,
                  address
              } = await User.findById({ _id: id }).select('image name gender about email phone address');
  
              const subscriptions = await Subscriber.countDocuments({ userId: id });
              const subscribers   = await Subscriber.countDocuments({ subscriberId: id });
  
              const user = {
                  image,
                  name,
                  gender,
                  subscriptions,
                  subscribers,
                  about,
                  email,
                  phone,
                  address
              };
  
              res.json(user);
  
          } catch (err) {
              console.log(err);
          }
  
      }
  </code></pre>
  
  <p>PS.
  I only study with this technologies</p>
  
  <p>If i used spread operator of result of my query from User i have like this:
  <a href="https://i.stack.imgur.com/7uYIq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7uYIq.png" alt="enter image description here"></a></p>
  
  <p>And that what i have in result</p>
  
  <pre><code>module.exports = {
  
      getProfile: async (req, res) =&gt; {
          const { id } = req.params;
  
          try {
  
              const [data, subscriptions, subscribers] = await Promise.all([
                  User.findById( { _id: id },
                      {
                          __v: false,
                          password: false,
                          date: false,
                          _id: false
                      },
                  ),
                  Subscriber.countDocuments({ userId: id }),
                  Subscriber.countDocuments({ subscriberId: id })
              ])
  
              const user = {
                  ...data._doc,
                  subscriptions,
                  subscribers
              }
  
              res.json(user);
  
          } catch (err) {
              console.log(err);
          }
  
      }
  
  
  </code></pre>