title: How do I get one document from MongoDB with ID from URL using javascript
body: <p>I'm making a basic movie app project, my movie Schema looks like this:</p>
  <pre><code>const movieSchema = new mongoose.Schema({
      name: {
          type: String,
          required: true
      },
      genre: {
          type: String,
          required: true,
          lowercase: true,
          trim: true,
          enum: ['comedy', 'horor', 'romantic', 'action']
      }
  });
  
  const Movie = mongoose.model('Movie', movieSchema);
  </code></pre>
  <p>I'm trying to get one movie by id but this way it doesn't work</p>
  <pre><code>async function getMovie(id) {;
      return await Movie
          .find({&quot;_id&quot;: {id}})
          .select('name genre')
  }
  
  
  router.get(&quot;/:id&quot;, async(req, res) =&gt; {
      try{
      const movie = await getMovie(req.params.id);
      if (!movie) return res.status(404).send(&quot;The genre with the given ID does not exist.&quot;);
      console.log(movie);
      res.send(movie);
      }
      catch(err){
          console.log(&quot;Error&quot;, err)
      }
  });
  </code></pre>
  <p>I'm getting two errors:</p>
  <ol>
  <li>Error CastError: Cast to ObjectId failed for value &quot;{ id:
  '5f74c795cd1c5c22e82c18c6' }&quot; at path &quot;_id&quot; for model &quot;Movie&quot;</li>
  <li>Error: Argument passed in must be a single String of 12 bytes or a
  string of 24 hex characters</li>
  </ol>
  <p>How should I properly write this code?
  Btw using postman for checking requests</p>