Hi,
I’m curious if I had choose the right query for the quiz at the end of the chapter. I found 1020 documents, I am right?
How many did you find?
Hi,
I’m curious if I had choose the right query for the quiz at the end of the chapter. I found 1020 documents, I am right?
How many did you find?
I think I did the same thing initially, while constructing my solution because I also got 1020 documents at that step. Assuming that you did what I did, if you look at the 6th document, none of the scores satisfy the criteria.
My completed query yielded 744. Spot checking the results seem to confirm this, but it would be nice to have confirmation! If no one can confirm, I guess I’ll have to start looking at all 744 documents.
I got 1020 as well
i used
db.scores.find({$and: [{results: {$gte: 70}, results: {$lt:80}}]}).count()
Yes, the answer is 744. This query will be solved by using the $elemMatch Operator as follows:
{“results”: {$elemMatch: {$gte:70, $lt:80}}}. Am I right @Kanika?
What would be the difference between:
db.scores.find( { “results”: { “$elemMatch”: { “$gte”: 70, “$lt”: 80 } } } )
db.scores.find( { “results”: { “$gte”: 70, “$lt”: 80 } } )