//数据源为collectionList
<unicloud-db ref="udb" :collection="collectionList" :where="where" page-data="replace" :orderby="orderby"
:getcount="true" :page-size="options.pageSize" :page-current="options.pageCurrent"
v-slot:default="{data,pagination,loading,error,options}" :options="options" loadtime="manual"
@load="onqueryload">
//collectionList的定义
collectionList: [
db.collection('Wenzhou-order').field(
'ReceivingOrders_id,deliveryer_id'
).getTemp(),
db.collection('uni-id-users').field('nickname as text, _id').getTemp()
],
//界面搜索传入的参数
<uni-th align="center" filter-type="search"
@filter-change="filterChange($event, 'ReceivingOrders_id.text')">下单员名称</uni-th>
<uni-th align="center" filter-type="search"
@filter-change="filterChange($event, 'deliveryer_id.text')">配送员名称</uni-th>
//执行搜索的函数
filterChange(e, name) {
this._filter[name] = {
type: e.filterType,
value: e.filter
}
console.log(e.filter)
console.log(name)
this.where = name + "== '" + e.filter + "'"
console.log(this.where);
this.$nextTick(() => {
this.$refs.udb.loadData()
})
}
//schema
"ReceivingOrders_id": {
"bsonType": "string",
"title": "下单员名称",
"description": "下单者ID,参考`uni-id-users` 表",
"foreignKey": "uni-id-users._id",
"defaultValue": {
"$env": "uid"
}
},
"deliveryer_id": {
"bsonType": "string",
"title": "配送员名称",
"description": "配送员ID,参考`uni-id-users` 表",
"foreignKey": "uni-id-users._id",
"enum": {
"collection": "uni-id-users",
"field": "nickname as text, _id as value"
},
"defaultValue": ""
},
数据表大约有2万条数据,我的疑问是ReceivingOrders_id字段在界面搜索能成功,但是deliveryer_id字段就搜索超时,要求优化,我看了https://doc.dcloud.net.cn/uniCloud/db-performance.html 这里也没看的懂,不知道怎么设置索引和优化联表才可以生效,麻烦赐教
hws007
请问怎么利用_id分页!_id可以比大小吗!
2025-01-03 00:45
DCloud_uniCloud_CRL
回复 hws007: 可以了解一下游标分页
2025-01-03 13:05