Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. const Score = db.collection('Score')
  2.  
  3.  
  4.  
  5. app.get('/', async (req, res) => {
  6. const result = await Score.aggregate([
  7.  
  8. { $sort: {score: -1}},
  9. { $limit: 10}
  10.  
  11. ])
  12. console.log("get")
  13. res.status(200)
  14. .send(result)
  15. })
  16.  
  17.  
  18. app.post('/', async (req, res) => {
  19. const result = await Score.insert(req.body)
  20. console.log("Post")
  21. res.status(200).send(result)
  22. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement