/class-03/class03-resolved-educostachaves-EduardoChaves.md

https://gitlab.com/BelinhaIsis/be-mean-instagram-mongodb-exercises · Markdown · 67 lines · 52 code · 15 blank · 0 comment · 0 complexity · 4ccdcedace4f1d46d249899cc0ee75a6 MD5 · raw file

  1. # MongoDB - Aula 03 - Exercício
  2. autor: Eduardo Chaves
  3. ## Liste todos Pokemons com a altura **menor que** 0.5;
  4. ```
  5. > var query = {height: {$lt: 0.5}}
  6. > db.pokemons.find(query)
  7. { "_id" : ObjectId("564faaaf793b2b526913ebd0"), "name" : "Ninetales", "description" : "Its nine tails are said to be imbued with a mystic power. It can live for a thousand years.", "type" : "fogo", "attack" : 76, "defense" : 75, "height" : 0.3 }
  8. { "_id" : ObjectId("564faaaf793b2b526913ebd1"), "name" : "Grimer", "description" : "Appears in filthy areas. Thrives by sucking up polluted sludge that is pumped out of factories.", "type" : "veneno", "attack" : 80, "defense" : 50, "height" : 0.4 }
  9. { "_id" : ObjectId("564faaaf793b2b526913ebd2"), "name" : "Dewgong", "description" : "Stores thermal energy in its body. Swims at a steady 8 knots even in intensely cold waters.", "type" : "água", "attack" : 70, "defense" : 80, "height" : 0.2 }
  10. { "_id" : ObjectId("564faaaf793b2b526913ebd4"), "name" : "Nidorina", "description" : "When NIDORINA are with their friends or family, they keep their barbs tucked away to prevent hurting each other.", "type" : "veneno", "attack" : 62, "defense" : 67, "height" : 0.4 }
  11. >
  12. ```
  13. ## Liste todos Pokemons com a altura **maior ou igual que** 0.5
  14. ```
  15. > var query = {height: {$gte: 0.5}}
  16. > db.pokemons.find(query)
  17. { "_id" : ObjectId("564f9168793b2b526913ebc8"), "name" : "Ivysaur", "description" : "Mostro de feito de plantas", "type" : "grama", "attack" : 65, "defense" : 41, "height" : 1 }
  18. { "_id" : ObjectId("564f9168793b2b526913ebc9"), "name" : "Blastoise", "description" : "Monstro de água muito poderoso", "type" : "água", "attack" : 75, "defense" : "32", "height" : 1.6 }
  19. { "_id" : ObjectId("564f9168793b2b526913ebca"), "name" : "Venusaur", "description" : "Monstro de veneno muito poderoso", "type" : "grama", "attack" : 82, "defense" : "68", "height" : 2.2 }
  20. { "_id" : ObjectId("564f9168793b2b526913ebcb"), "name" : "Mega Venusaur", "description" : "Monstro de grama e veneno extremamente poderoso", "type" : "grama", "attack" : 100, "defense" : "90", "height" : 2.4 }
  21. { "_id" : ObjectId("564f9168793b2b526913ebcc"), "name" : "Charmeleon", "description" : "Monstro de Fogo muito poderoso", "type" : "fogo", "attack" : 32, "defense" : "31", "height" : 1.1 }
  22. { "_id" : ObjectId("564faaaf793b2b526913ebce"), "name" : "Butterfree", "description" : "Its wings, covered with poisonous powders, repel water.", "type" : "inseto", "attack" : 45, "defense" : 50, "height" : 0.8 }
  23. { "_id" : ObjectId("564faaaf793b2b526913ebcf"), "name" : "Arbok", "description" : "The frightening patterns on its belly have been studied. Six variations have been confirmed.", "type" : "veneno", "attack" : 85, "defense" : 69, "height" : 0.6 }
  24. { "_id" : ObjectId("564faaaf793b2b526913ebd3"), "name" : "Beedrill", "description" : "It can take down any opponent with its powerful poi son stingers.", "type" : "inseto", "attack" : 90, "defense" : 40, "height" : 10 }
  25. >
  26. ```
  27. ## Liste todos Pokemons com a altura **maior ou igual que** 0.5 **E** do tipo grama
  28. ###(mudei para maior que por que não tenho do tipo grama com alturas menores ou igual a 0.5)
  29. ```
  30. > var query = {$and: [{height: {$gte: 0.5}}, {type: "grama"}]}
  31. > db.pokemons.find(query)
  32. { "_id" : ObjectId("564f9168793b2b526913ebc8"), "name" : "Ivysaur", "description" : "Mostro de feito de plantas", "type" : "grama", "attack" : 65, "defense" : 41, "height" : 1 }
  33. { "_id" : ObjectId("564f9168793b2b526913ebca"), "name" : "Venusaur", "description" : "Monstro de veneno muito poderoso", "type" : "grama", "attack" : 82, "defense" : "68", "height" : 2.2 }
  34. { "_id" : ObjectId("564f9168793b2b526913ebcb"), "name" : "Mega Venusaur", "description" : "Monstro de grama e veneno extremamente poderoso", "type" : "grama", "attack" : 100, "defense" : "90", "height" : 2.4 }
  35. >
  36. ```
  37. ## Liste todos Pokemons com o name `Pikachu` **OU** com attack **menor ou igual que** 0.5
  38. ```
  39. > var query = {$and: [{name: "Pikachu"}, {attack: {$lte: 0.5}}]}
  40. > db.pokemons.find(query)
  41. >
  42. ```
  43. ## Liste todos Pokemons com o attack **MAIOR OU IGUAL QUE** 48 **E** com height **menor ou igual que** 0.5
  44. ```
  45. > var query = {$and: [{height: {$lte: 0.5}}, {attack: {$gte: 48}}]}
  46. > db.pokemons.find(query)
  47. { "_id" : ObjectId("564faaaf793b2b526913ebd0"), "name" : "Ninetales", "description" : "Its nine tails are said to be imbued with a mystic power. It can live for a thousand years.", "type" : "fogo", "attack" : 76, "defense" : 75, "height" : 0.3 }
  48. { "_id" : ObjectId("564faaaf793b2b526913ebd1"), "name" : "Grimer", "description" : "Appears in filthy areas. Thrives by sucking up polluted sludge that is pumped out of factories.", "type" : "veneno", "attack" : 80, "defense" : 50, "height" : 0.4 }
  49. { "_id" : ObjectId("564faaaf793b2b526913ebd2"), "name" : "Dewgong", "description" : "Stores thermal energy in its body. Swims at a steady 8 knots even in intensely cold waters.", "type" : "água", "attack" : 70, "defense" : 80, "height" : 0.2 }
  50. { "_id" : ObjectId("564faaaf793b2b526913ebd4"), "name" : "Nidorina", "description" : "When NIDORINA are with their friends or family, they keep their barbs tucked away to prevent hurting each other.", "type" : "veneno", "attack" : 62, "defense" : 67, "height" : 0.4 }
  51. >
  52. ```