代码流程
1. 数组1查询
const AllTourGuide = await this._TourGuide.findAll({
include: this._getAssociationOptionsForTime()
})
let arr = []
for (let leave of AllTourGuide) {
if (leave.tour_guide_leaves.length === 0) {
arr.push(leave)
}
}
arr数组
2. 数组2查询
let where = { attractionId }
let include = null
if (Time) {
include = this._getAssociationOptionForTime(Time)
} else {
include = this._getAssociationOptionsForTime()
}
const options = {
where,
include
}
const leaveGuide = await this._TourGuide.findAll(options)
3.返回数组1,数组2 并对返回的数组分页
return this.getpaging(currentPage, Count, result)
}
getpaging (currentPage, count, result) {
return result.slice((currentPage - 1) * count, currentPage * count)
}
4. slice(start,end):返回从原数组中指定开始下标到结束下标之间的项组成的新数组
result.slice((currentPage - 1) * count, currentPage * count)
sequlize相关 https://www.jianshu.com/p/84f65edf4174