Friday 15 August 2014

javascript - Iterate through a Sorted Mongoose Collection -


I am new to JavaScript, MongoDB, and Mongoose.

I have a collection of "students" from DB "Demode" in my JavaScript file, I have created a monoz schema called "student" for "student" with a "name" near a "student" "," Gender ", and" major "(all types of string).

I want to be able to sort students from the field for the first time (alphabetically "name") and then for each student execute some tasks using the Congo within JavaScript Does.

I have looked around, but I got the syntax for opening Mongo (not what I want) or examples which do not work for me.

I am familiar with Java and would like to do something that is ideally suited in this way (after sorting).

  
  (students.hasNext ()) for (object current student: students) {// do something}   

Any such thing will be good. ) {Object current student = students.?; // Some commands / something to store the existing student}

Thanks, I apologize if this question seems trivial in advance.

node. In JS, your head around ASINCC programming is a little bit if you are new to concepts.

Actually

If you type then

 < Code> for (var i = 0; i & lt; objects.length; i ++) {var object = objects [i] db.save (object, function (fault, result) {}}  < / Pre> 

All saved operations are executed in parallel, in Java, you will not expect successively like this. It's wrapped around your head. You can use some libraries like Phase or Async, which can help you with calls and iteration of oration.

No comments:

Post a Comment