/class-03/class-03-resolved-paulosilva92-Paulo-Roberto-da-Silva.md

https://github.com/Webschool-io/be-mean-instagram-mongodb-exercises · Markdown · 118 lines · 113 code · 5 blank · 0 comment · 0 complexity · bf155ca1c0ce952e9ff7835abe24d459 MD5 · raw file

  1. # MongoDb - Aula 03 - Exercício
  2. Autor: Paulo Roberto da Silva
  3. ## Listagem pokemons height < 0.5
  4. ```js
  5. paulo(mongod-3.2.1) be-mean-pokemons> var query = {height : {$lt:0.5}}
  6. paulo(mongod-3.2.1) be-mean-pokemons> db.pokemons.find(query);
  7. Fetched 0 record(s) in 1ms
  8. ```
  9. ## Listagem pokemons height >= 0.5
  10. ```js
  11. paulo(mongod-3.2.1) be-mean-pokemons> var query = {height : {$gte:0.5}}
  12. paulo(mongod-3.2.1) be-mean-pokemons> db.pokemons.find(query);
  13. {
  14. "_id": ObjectId("56b784d94a6ae70439c45bca"),
  15. "name": "Butterfree",
  16. "description": "Its wings, covered with poisonous powders, repel water.",
  17. "type": "inseto",
  18. "attack": 45,
  19. "defense": 50,
  20. "height": 11
  21. }
  22. {
  23. "_id": ObjectId("56b784d94a6ae70439c45bcb"),
  24. "name": "Arbok",
  25. "description": "The frightening patterns on its belly have been studied. Six variations have been confirmed.",
  26. "type": "veneno",
  27. "attack": 85,
  28. "defense": 69,
  29. "height": 35
  30. }
  31. {
  32. "_id": ObjectId("56b784d94a6ae70439c45bcc"),
  33. "name": "Ninetales",
  34. "description": "Its nine tails are said to be imbued with a mystic power. It can live for a thousand years.",
  35. "type": "fogo",
  36. "attack": 76,
  37. "defense": 75,
  38. "height": 11
  39. }
  40. {
  41. "_id": ObjectId("56b784d94a6ae70439c45bcd"),
  42. "name": "Grimer",
  43. "description": "descricao alterada",
  44. "type": "veneno",
  45. "attack": 80,
  46. "defense": 50,
  47. "height": 9
  48. }
  49. {
  50. "_id": ObjectId("56b784d94a6ae70439c45bce"),
  51. "name": "Nidorina",
  52. "description": "When NIDORINA are with their friends or family, they keep their barbs tucked away to prevent hurting each other.",
  53. "type": "veneno",
  54. "attack": 62,
  55. "defense": 67,
  56. "height": 8
  57. }
  58. Fetched 5 record(s) in 5ms
  59. ```
  60. ## Listagem pokemons height <= 0.5 e type "grama"
  61. ```js
  62. paulo(mongod-3.2.1) be-mean-pokemons> var query = {$and: [{height:{$lte:0.5}},{type:'grama'}]}
  63. paulo(mongod-3.2.1) be-mean-pokemons> db.pokemons.find(query)
  64. Fetched 0 record(s) in 1ms
  65. ```
  66. ## Listagem pokemons name "Pikachu" ou attack <= 0.5
  67. ```
  68. paulo(mongod-3.2.1) be-mean-pokemons> var query = {$or : [{name:'Pikachu'}, {attack: {$lte: 0.5}}]}
  69. paulo(mongod-3.2.1) be-mean-pokemons> db.pokemons.find(query)
  70. Fetched 0 record(s) in 1ms
  71. ```
  72. ## Listagem pokemons attack >= 48 e height <= 0.5
  73. ```js
  74. paulo(mongod-3.2.1) be-mean-pokemons> var query = {$or : [{attack: {$gte: 48}}, {height: {$lte: 0.5}}]}
  75. paulo(mongod-3.2.1) be-mean-pokemons> db.pokemons.find(query)
  76. {
  77. "_id": ObjectId("56b784d94a6ae70439c45bcb"),
  78. "name": "Arbok",
  79. "description": "The frightening patterns on its belly have been studied. Six variations have been confirmed.",
  80. "type": "veneno",
  81. "attack": 85,
  82. "defense": 69,
  83. "height": 35
  84. }
  85. {
  86. "_id": ObjectId("56b784d94a6ae70439c45bcc"),
  87. "name": "Ninetales",
  88. "description": "Its nine tails are said to be imbued with a mystic power. It can live for a thousand years.",
  89. "type": "fogo",
  90. "attack": 76,
  91. "defense": 75,
  92. "height": 11
  93. }
  94. {
  95. "_id": ObjectId("56b784d94a6ae70439c45bcd"),
  96. "name": "Grimer",
  97. "description": "descricao alterada",
  98. "type": "veneno",
  99. "attack": 80,
  100. "defense": 50,
  101. "height": 9
  102. }
  103. {
  104. "_id": ObjectId("56b784d94a6ae70439c45bce"),
  105. "name": "Nidorina",
  106. "description": "When NIDORINA are with their friends or family, they keep their barbs tucked away to prevent hurting each other.",
  107. "type": "veneno",
  108. "attack": 62,
  109. "defense": 67,
  110. "height": 8
  111. }
  112. Fetched 4 record(s) in 4ms
  113. ```