Skip to content

Instantly share code, notes, and snippets.

@alfonmga
Created March 28, 2019 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfonmga/89bdbcd3bf7d7292a62c00cbf25994d4 to your computer and use it in GitHub Desktop.
Save alfonmga/89bdbcd3bf7d7292a62c00cbf25994d4 to your computer and use it in GitHub Desktop.
/**
* List users in descending order of 'createdAt' timestamp.
* @param {number} skip - Number of users to be skipped.
* @param {number} limit - Limit number of users to be returned.
* @returns {Promise<User[]>}
*/
list({ skip = 0, limit = 50 } = {}) {
return this.find()
.sort({ createdAt: -1 })
.skip(+skip)
.limit(+limit)
.exec();
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment