Diferències

Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.

Enllaç a la visualització de la comparació

Ambdós costats versió prèvia Revisió prèvia
Següent revisió
Revisió prèvia
info:cursos:mongodbuniversity:m001:cap3 [15/12/2018 09:09] – [operators] mateinfo:cursos:mongodbuniversity:m001:cap3 [15/12/2018 10:16] (actual) – [Challenge Problem] mate
Línia 124: Línia 124:
 Si queremos buscar correctamente, se ha de usar ''$elemMatch''. En este caso, este documento no será devuelto pq no satisface la condición impuesta: Si queremos buscar correctamente, se ha de usar ''$elemMatch''. En este caso, este documento no será devuelto pq no satisface la condición impuesta:
 <code javascript>db.movieDetails.find({boxOffice: {$elemMatch: {"country": "Germany", "revenue": {$gt: 17}}}})</code> <code javascript>db.movieDetails.find({boxOffice: {$elemMatch: {"country": "Germany", "revenue": {$gt: 17}}}})</code>
- 
- 
-<code javascript></code> 
-<code javascript></code> 
  
 == regex operator == regex operator
Línia 147: Línia 143:
 <code javascript>db.movieDetails.find({"awards.text": {$regex: /^Won.* /}}, {_id: 0, title: 1, "awards.text": 1}).pretty() <code javascript>db.movieDetails.find({"awards.text": {$regex: /^Won.* /}}, {_id: 0, title: 1, "awards.text": 1}).pretty()
 </code> </code>
 +
 +== Challenge Problem
 +Connect to our class Atlas cluster from the mongo shell or Compass and view the results.scores collection. How many documents contain at least one score in the results array that is greater than or equal to 70 and less than 80?
 +<code javascript>{$and: [{"results": {$gte: 70}}, {"results": {$lt: 80}}] }  // WRONG! --> RIGHT! (no leer bien el enunciado)</code>
 +
 +<code javascript>{"results": {$in: [{$gte: 70}, {$lt: 90}] } }  // WRONG!</code>
 +
 +== Final Exam
 +<button collapse="exam" size="xs">Algunas respuestas...</button>
 +
 +<collapse id="exam" collapsed="true">
 +
 +  * 4: Please connect to the M001 class Atlas cluster. You may answer this question using either the mongo shell or Compass.
 +
 +For this question we will use the citibike database.
 +
 +How many documents in the citibike.trips collection have the key tripduration set to null? Ignore any documents that do not contain the tripduration key.<code javascript>{$and: [{tripduration: {$exists: true}}, {tripduration: { $eq: null}} ] }</code>
 +  * 6: Please connect to the M001 class Atlas cluster from the mongo shell or Compass and view the video.movies collection. How many movies match the following criteria?
 +
 +The cast includes either of the following actors: "Jack Nicholson", "John Huston".
 +The viewerRating is greater than 7.
 +The mpaaRating is "R".<code javascript>{ cast: {$in:["Jack Nicholson","John Huston"]}, viewerRating:{$gt:7},mpaaRating:"R" }</code>
 +
 +</collapse>
  • info/cursos/mongodbuniversity/m001/cap3.1544893776.txt.gz
  • Darrera modificació: 15/12/2018 09:09
  • per mate