Pagination query func is chainable now
This commit is contained in:
parent
513af3a56b
commit
e0b37bbf33
2 changed files with 3 additions and 1 deletions
|
@ -64,6 +64,7 @@ export default {
|
||||||
pagedSpells () {
|
pagedSpells () {
|
||||||
return new Query(this.sortedSpells)
|
return new Query(this.sortedSpells)
|
||||||
.paginate(this.page, this.perPage)
|
.paginate(this.page, this.perPage)
|
||||||
|
.results
|
||||||
},
|
},
|
||||||
sortedSpells () {
|
sortedSpells () {
|
||||||
return this.spells
|
return this.spells
|
||||||
|
|
|
@ -34,6 +34,7 @@ export default class Query {
|
||||||
paginate (page = 1, perPage = 10) {
|
paginate (page = 1, perPage = 10) {
|
||||||
let min = page * perPage - perPage
|
let min = page * perPage - perPage
|
||||||
let max = min + perPage
|
let max = min + perPage
|
||||||
return this.data.slice(min, max)
|
this.data = this.data.slice(min, max)
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue