title: Select a document from Mongodb by providing param in NodeJs
body: <p>I want to request a certain userId via NodeJs but I always receive all documents from MongoDb, independent of the userId I provide.</p>
  <p>This is my route:</p>
  <pre><code>router.get('/wallet/showWallet/', walletController.showWallet)
  </code></pre>
  <p>Controller:</p>
  <pre><code>const showWallet = async(req,res)=&gt;{
      try {
          let user = req.query.userId;
          const wallet = await walletService.getWalletById(user);
          res.json(wallet);
       } catch (error) {
          res.status(500).json({error: error})
       }
  }
  </code></pre>
  <p>Service:</p>
  <pre><code>function walletService() {
      function getWalletById(user) {
          try {
              const walletResponse =  walletModel.find({userId: new ObjectId(user)}, {amount: 1, _id: 0});1, _id: 0});
              return walletResponse;
          } catch (error) {
              console.log(`Wallet not found. ${error}`)
          }       
      }
      return {
          getWalletById: getWalletById,
      }
  }
  </code></pre>
  <p>Model:</p>
  <pre><code>const mongoose  = require(&quot;mongoose&quot;)
  
  const walletModel = new mongoose.Schema({
      userId: {
          type: mongoose.Schema.Types.ObjectId,
          required: true,
          ref : 'User'
      },
      amount: {
          type: Number
      },
      last_recharge_date: {
          type: Date
      },
      expiry_date: {
          type: Date
      },
      isDeleted: {
          type: Boolean
      },
      isActive: {
          isActive: Boolean
      },
  })
  
  const wallet = mongoose.model(&quot;wallets&quot;, walletModel)
  module.exports = wallet;
  </code></pre>
  <p>Postman:</p>
  <p>https://someUrl/api/wallet/showWallet?userId=626b9f5908b0fef1b09a55e4</p>
  <p>MongoDb:</p>
  <p><a href="https://i.stack.imgur.com/w99Jr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w99Jr.png" alt="enter image description here" /></a></p>
  <p>Result from Postman:</p>
  <p><a href="https://i.stack.imgur.com/pMeyr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pMeyr.png" alt="enter image description here" /></a></p>
  <p>I really cannot find a way to solve this problem!</p>
  <p>Maybe somebody can help me, please?</p>
  <p>Thanks in advance!</p>