# Collection.limit / Query.limit

Specifies the maximum number of result sets.

The method signature is shown as below:

function limit(max: number): Collection | Query

The method accepts a required parameter max to define the number of returned maximum result sets, which is up to 20.

Sample code

const db = wx.cloud.database()
db.collection('todos').limit(10)
  .get()
  .then(console.log)
  .catch(console.error)