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 :: firestore add document 
Javascript :: select default value react 
Javascript :: js reduce break 
Javascript :: vue.js slots 
Javascript :: is node js faster than python 
Javascript :: iiee javascript 
Javascript :: convert date to readable format javascript 
Javascript :: styled components import google font 
Javascript :: mongodb connection string node example localhost 
Javascript :: open cypress window 
Javascript :: reactbootstrap multiselect 
Javascript :: href="javascript:void(null);" 
Javascript :: safeareaview react native android 
Javascript :: array from set javascript 
Javascript :: get all global variables javascript 
Javascript :: javascript take last n elements of array 
Javascript :: convert number to word js 
Javascript :: merge 2 dictionaries with same keys javascript 
Javascript :: sh: /Users/ahmedqadri/Desktop/Projects/stockNotesAPP-frontend/node_modules/.bin/react-scripts: Permission denied 
Javascript :: exclude file types from formater vscode 
Javascript :: react transition group 
Javascript :: java gson string to json 
Javascript :: sort javascript number array with duplicates 
Javascript :: javascript date to firebase timestamp 
Javascript :: add a Google Font to a VueJS 
Javascript :: check if key does not exists in dictionary javascript 
Javascript :: datatable order number 
Javascript :: what is cdn react 
Javascript :: react native floating button 
Javascript :: how to get single element from nested array mongoose 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =