Apply for Zend Framework Certification Training


Sort() is the not a method hence it can not be used standalone so we, 
in most of the cases, use it along with find() method of mongodb.
It is used to sort the collection in either ascending of descending order.

//condition "1" for sorting in Ascending order on the basis of "age"	
	var method = { age : 1 };
	//accessing the collection
		.toArray( (err , collection) => {
		if(err) throw err;
		//console.log(collection.result.n + "Record(s) deleted successfully");
	//escending order on the basis of "name"	
	var method = { name : -1 };

< Uses of updateOne and updateMany in mongoDb Uses of $pull in mongoDb with nodeJs >

Ask a question

  • Question:
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question

Back to Top