-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
表结构
OperatingRecordSchema = new Schema({
product_id: { // 商品ID
type: Schema.ObjectId,
required: true,
index: true
},
product_name: String, //商品名称
count: Number, // 商品的数量
operator: String, //操作人
operate_status: { // 操作状态【入库 0 | 出库 1 】
type: Number,
required: true
},
user_to_id: { // 收货人id from contact
type: Schema.ObjectId,
index: true
},
user_to_name:String,
user_to_address: String,
user_to_phone: String,
user_name: String, //发货人姓名
user_id: { // 用户的id
type: Schema.ObjectId,
// required: true,
index: true
},
created_at: {
type: Date,
default: Date.now
}
});
现在数据库有10条数据(按顺序创建的)
PageSize为5, 根据 created_at 升序排序时一切正常:
使用 top 第一次加载5条:
1
2
3
4
5 <-- last_index
点击加载更多(使用 pageByLastId 再加载5条):
1
2
3
4
5
6
7
8
9
10
当根据 created_at 降序排序时:
使用 top 第一次加载5条:
10
9
8
7
6 <-- last_index
点击加载更多(使用 pageByLastId 再加载5条)出现了问题:
排序变成了这样:
10
9
8
7
6
10
9
8
7
这次使用 pageByLastId 只加载出了 4条数据,而且 10,9,8,7 重复地取出来了
Metadata
Metadata
Assignees
Labels
No labels