Skip to content

Instantly share code, notes, and snippets.

@adrianlemess
Last active June 4, 2018 22:48
Show Gist options
  • Save adrianlemess/f62eb7f8a27d9edb7ed5cf29ed21548d to your computer and use it in GitHub Desktop.
Save adrianlemess/f62eb7f8a27d9edb7ed5cf29ed21548d to your computer and use it in GitHub Desktop.

MongoDB LAB

Crie uma API que use uma database com o nome mongo_aula. Essa API deve ter endpoints que possibile as operações abaixo.

Teste os endpoints (as rotas) da API através do POSTMAN!

Inserir Documentos

Insira os seguintes documentos em uma coleção de movies.

title : Fight Club
writer : Chuck Palahniuk
year : 1999
actors : [
  Brad Pitt
  Edward Norton
]
title : Pulp Fiction
writer : Quentin Tarantino
year : 1994
actors : [
  John Travolta
  Uma Thurman
]
title : Inglorious Basterds
writer : Quentin Tarantino
year : 2009
actors : [
  Brad Pitt
  Diane Kruger
  Eli Roth
]
title : The Hobbit: An Unexpected Journey
writer : J.R.R. Tolkein
year : 2012
franchise : The Hobbit
title : The Hobbit: The Desolation of Smaug
writer : J.R.R. Tolkein
year : 2013
franchise : The Hobbit
title : The Hobbit: The Battle of the Five Armies
writer : J.R.R. Tolkein
year : 2012
franchise : The Hobbit
synopsis : Bilbo and Company are forced to engage in a war against an array of combatants and keep the Lonely Mountain from falling into the hands of a rising darkness.
title : Pee Wee Herman's Big Adventure
title : Avatar

Query / Busca de Documentos

Realize as seguintes queries na coleção de movies.

  1. Buscar todos os documentos.
  2. Buscar um documento apenas por _id
  3. Pegar todos os documentos onde actors inclui "Brad Pitt"
  4. Pegar todos os documentos com franchise igual a "The Hobbit"
  5. Buscar todos os filmes lançados nos anos 90s
  6. Buscar todos os filmes lançados entre 2000 e 2010 (incluindo 2000 e 2010)
  7. Pegar todos os documentos com writer igual a "Quentin Tarantino"

Update Documents

  1. Adicione a sinopse (synopsis) em "The Hobbit: An Unexpected Journey" : "A reluctant hobbit, Bilbo Baggins, sets out to the Lonely Mountain with a spirited group of dwarves to reclaim their mountain home - and the gold within it - from the dragon Smaug."
  2. Adicione a sinopse (synopsis) em "The Hobbit: The Desolation of Smaug" : "The dwarves, along with Bilbo Baggins and Gandalf the Grey, continue their quest to reclaim Erebor, their homeland, from Smaug. Bilbo Baggins is in possession of a mysterious and magical ring."
  3. Adicione o ator "Samuel L. Jackson" ao filme "Pulp Fiction"

Delete Documents

  1. Delete o filme "Pee Wee Herman's Big Adventure"
  2. Delete o filme "Avatar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment