WeChat applet cloud development (9) - "return the specified number of rows limit() and paging skip()"

1. Return the specified number of rows limit()

limit is used to specify the upper limit of the number of query result sets. For example, we have 100 pieces of data and only want to return the first 20 pieces. We can use limit(20) to specify that only 20 pieces of data are returned.

For example, the way to return only 3 pieces of data is as follows
insert image description here
Note:The default and maximum limit on the applet side is 20, and the default and maximum limit on the cloud function side is 1000

2. Paging method skip()

skip specifies that when the query returns results, it returns from the results after the specified sequence, which is often used for pagination. For example, if we have 100 pieces of data and want to return data from the 10th piece, we can use skip(10) to achieve

Skip combined with the limit method we learned above can achieve the pagination effect.
insert image description here
For example, if we have 100 pieces of data, 20 pieces of data are returned each time. Then you can return in 5 pages.

  • Page 1 limit(20).skip(0)
  • Page 2 limit(20).skip(20)
  • Page 3 limit(20).skip(40)
  • Page 4 limit(20).skip(60)
  • Page 5 limit(20).skip(80)

Guess you like

Origin blog.csdn.net/qq_47354826/article/details/119485339