Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
MongoDB/node.js - How to find all movies of the same genre by "Name"?

I am building a 'netflix' style app for practice. In it, I want the user to be able to find all movies of a certain genre by typing in the following url:

http://localhost:8080/movies/Adventure

But I seem to be going wrong somewhere, because the list returns null... here is my code:

app.get('/movies/:genre', (req, res) => {
                Movies.find({ 
                    Genre: { Name: req.params.genre } 
                  }).populate('Genre Director Actors')
                  .then((movie) => {
                    res.json(movie);
                  }).catch((err) => {
                    console.error(err);
                    res.status(500).send('Error: ' + err);
                  });
                });

and this is the data from MongoDB:

"Genre": [
{
"_id": "611b4b465bf9b8645dd32ef9",
"Name": "Animated",
"Description": "Animation is a method in which pictures are manipulated to appear as moving images. In traditional animation, images are drawn or painted by hand on transparent celluloid sheets to be photographed and exhibited on film."
}
],
"Actors": [
{
"_id": "611bd09659f7b8323ad90441",
"Name": "Johnny Depp",
"Bio": "John Christopher Depp II is an American actor, producer, and musician. He is the recipient of various accolades, including a Golden Globe Award and a Screen Actors Guild Award, in addition to nominations for three Academy Awards and two British Academy Film Awards.",
"Birth": "1963-06-09",
"Death": "N/A"
}
],
"_id": "611c06f4cb359ae2b8220245",
"Title": "Rango",
"Description": "A chameleon (Johnny Depp) who has lived as a sheltered family pet finds himself in the grip of an identity crisis. Rango wonders how to stand out when it is his nature to blend in. When he accidentally winds up in a frontier town called Dirt, he takes the first step on a transformational journey as the town's new sheriff. Though at first Rango only role-plays, a series of thrilling situations and outrageous encounters forces him to become a real hero.",
"Director": {
"_id": "611b4f835bf9b8645dd32efe",
"Name": "Gore Verbinski",
"Bio": "Gregor Justin 'Gore' Verbinski is an American film director, screenwriter, producer, and musician. He is best known for directing The Ring, the Pirates of the Caribbean films, and Rango.",
"Birth": "1964-03-16",
"Death": "N/A"
},
"ImagePath": "rango.png",
"Featured": false
}

All help is appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Movies.find({ "Genre.Name": req.params.genre })
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda