Note that there are some explanatory texts on larger screens.

plurals
  1. POPulling out latest (multiple) entries from MongoDB
    text
    copied!<p>I am trying to retrieve information on how many attempts a user takes to solve a particular problem as a JSON from a mongodb database. If there are multiple attempts on the same problem, I would only like to pull out the last entry - for instance, right now, if I do a db.proficiencies.find() - I will pull out entries A, B, C, and D but I would like to only pull out entries B and D (latest entries for the problems maze and circle respectively).</p> <p>Is there an easy way to do so?</p> <pre><code>Entry A { "problem": "maze", "courseLesson": "elementary_one, 1", "studentId": "51ed51d0fcb4cc3696000001", "studentName": "Sarah", "_id": "51ed51defcb4cc3696000011", "__v": 0, "date": "2013-07-22T15:38:06.259Z", "numberOfAttemptsBeforeSolved": 1 } Entry B { "problem": "maze", "courseLesson": "elementary_one, 1", "studentId": "51ed51d0fcb4cc3696000001", "studentName": "Sarah", "_id": "51ed51defcb4cc3696000011", "__v": 0, "date": "2013-07-27T15:38:06.259Z", "numberOfAttemptsBeforeSolved": 1 } Entry C { "problem": "circle", "courseLesson": "elementary_one, 1", "studentId": "51ed51d0fcb4cc3696000001", "studentName": "Sarah", "_id": "51ed51defcb4cc3696000011", "__v": 0, "date": "2013-07-22T15:38:06.259Z", "numberOfAttemptsBeforeSolved": 2 } Entry D { "problem": "circle", "courseLesson": "elementary_one, 1", "studentId": "51ed51d0fcb4cc3696000001", "studentName": "Sarah", "_id": "51ed51defcb4cc3696000011", "__v": 0, "date": "2013-07-27T15:38:06.259Z", "numberOfAttemptsBeforeSolved": 4 } var ProficiencySchema = new Schema({ problem: String , numberOfAttemptsBeforeSolved: {type: Number, default: 0} //refers to which lesson, e.g. elementary_one, 2 refers to lesson 2 of elementary_one , courseLesson: String , date: {type: Date, default: Date.now} , studentId: Schema.Types.ObjectId , studentName: String }) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload