D
D
Dmitry Maksimyuk2021-04-13 17:33:32
Node.js
Dmitry Maksimyuk, 2021-04-13 17:33:32

How to make a mongoose filter?

I am using mongoose. There is a collection: 'Users', model: 'UserReg', with schema:

{
    id: Number,
    exp: Number,
    balance: Number,
    bonus: Number,
  };

How to get top users by balance? I tried $sort, but I didn’t find at least a similar answer from the documentation, that I searched for answers on the stack and other stack-like sites. Please help if you can, thanks!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
low molecular macro, 2021-04-13
@molekulyarniy

query.sort = "-balance";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question