Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mongodb sort query

db.Employee.find().sort({Employeeid:-1}).forEach(printjson)
Comment

mongoDB sort

  let limit = parseInt(req.body.limit) || 10
  let page = parseInt(req.body.page) - 1 || 0
  var query = {};
  let users = await Users.find({}).sort({ createdAt: -1 }).skip(limit * page).limit(limit).select("fields you want to select separated by space")
  const count = await Users.countDocuments(query);
  let obj = {
    Users: users,
    total: count,
    limit: limit,
    page: page + 1
  }
Comment

order by mongodb

db.people.find( { status: "A" } ).sort( { user_id: 1 } )
db.people.find( { status: "A" } ).sort( { user_id: -1 } )

-- sql
SELECT *
FROM people
WHERE status = "A"
ORDER BY user_id ASC

SELECT *
FROM people
WHERE status = "A"
ORDER BY user_id DESC
Comment

PREVIOUS NEXT
Code Example
Javascript :: clearinterval javascript 
Javascript :: How to pass data in Link of react-router-dom 
Javascript :: hoisting in javscript 
Javascript :: position of the mouse cursor javascript 
Javascript :: mongodb add 1 to field 
Javascript :: jsonb_set 
Javascript :: audio element javascript 
Javascript :: how to convert object to array in javascript 
Javascript :: node .env file example 
Javascript :: js ,flat 
Javascript :: get window height javascript 
Javascript :: edit embeds discord.js 
Javascript :: Mqtt js react-native 
Javascript :: save file javascript 
Javascript :: javascript unshift 
Javascript :: new date 
Javascript :: javascript for of loop 
Javascript :: Substring in Javascript using substr 
Javascript :: javascript add parameter to object 
Javascript :: enzyme react 
Javascript :: Create Your Own Node Module 
Javascript :: footer bottom 
Javascript :: react navbar material ui 
Javascript :: form an array from i to j javascript 
Javascript :: redux devtools config 
Javascript :: node js mongoose text index 
Javascript :: access shadow root element 
Javascript :: how to find element in array angularjs 
Javascript :: sort array in javascript 
Javascript :: angular map 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =