mongoose pagination
Try this:
if ( !docs ) { res.json({users: [], next: 0});}
if i got your question right you would like to send the ammount of remaining documents for the next query, if so you could query with limit * 2 but only return 'limit' documents, substract limit from docs.length and you will get the ammount of remaining documents for the next query.
there may be a better solution with a more adanvced query.