简体   繁体   中英

Does loopback 3 supports where filter with skip + limit?

我正在使用版本3进行环回,它是否支持使用“跳过”和“限制”的过滤器,我正在尝试申请分页。

For pagination, I have always used "offset" but in docs there is an option for skip also. Please checkout at skip in loopback3

If you want apply skip and limit with pagination. This code is help full for you.

example is now :

Users.getList = function (filter, cb) {
  Users.find({
    where: {
      condition
    },
    limit: filter.limit,
    skip: filter.skip
  })

}

You can use skip and limit in the loopback where condition. I assume that you are trying to get the answer for something like the query SELECT * FROM schemaName.tableName limit 10,5 using loopback, for that you can use the following peace of code

modelName.find({
   order: 'id DESC',
   skip: 10,
   limit: 5,
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM