aldinokemal

MongoDB - Query Modifier

Mar 27th, 2022
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // select count(*) from products
  2. db.products.find({}).count()
  3.  
  4. // select * from products limit 4
  5. db.products.find({}).limit(4)
  6.  
  7. // select * from products offset 2
  8. db.products.find({}).skip(2)
  9.  
  10. // select * from products limit 4 offset 2
  11. db.products.find({}).limit(4).skip(2)
  12.  
  13. // select * from products order by name asc, category desc
  14. db.products.find({}).sort({
  15.     name: 1,
  16.     category: -1
  17. })
Advertisement
Add Comment
Please, Sign In to add comment