Skip to content

Commit

Permalink
feat(db-ql): add page() method
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Oct 19, 2021
1 parent 4be2479 commit 1148e4a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/database-ql/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ export class Query {
return new Query(this._db, this._coll, this._fieldFilters, this._fieldOrders, option, this._withs)
}

/**
* 设置分页查询
* @param options { current: number, size: number} `current` 是页码,默认为 `1`, `size` 是每页大小, 默认为 10
*/
public page(options: { current: number, size: number } = { current: 1, size: 10 }) {
const current = options.current || 1
const size = options.size || 10
return this.skip((current - 1) * size).limit(size)
}

/**
* 克隆
* @returns Query
Expand Down

0 comments on commit 1148e4a

Please sign in to comment.