const db = uniCloud.database()
const newsCategoryCollectionName = 'news-categories'
const newsCategoryCollection = db.collection(newsCategoryCollectionName)
db.collection('news-categories').skip(0).limit(20).get({
getCount: true
});
产品分类: uniCloud/App
const db = uniCloud.database()
const newsCategoryCollectionName = 'news-categories'
const newsCategoryCollection = db.collection(newsCategoryCollectionName)
db.collection('news-categories').skip(0).limit(20).get({
getCount: true
});
{
"result": {
"affectedDocs": 2,
"code": 0,
"count": 2,
"data": [
{
"_id": "6460d1c7f43e60d7b693d0a4",
"create_date": "2023-05-14 12:19:19",
"description": "111",
"name": "1111111"
},
{
"_id": "6460d1e8819ce8deee50172a",
"create_date": "2023-05-14 12:19:52",
"description": "22222",
"name": "222"
}
],
"errCode": 0,
"errMsg": "",
"message": "",
"systemInfo": [
],
"timeCost": 1323
}
}
{
affectedDocs: 2,
data:
[ { _id: '6460d1c7f43e60d7b693d0a4',
name: '1111111',
description: '111',
create_date: '2023-05-14 12:19:19' },
{ _id: '6460d1e8819ce8deee50172a',
name: '222',
description: '22222',
create_date: '2023-05-14 12:19:52' } ] } { page: { total: 2 },
items:
[ { _id: '6460d1c7f43e60d7b693d0a4',
name: '1111111',
description: '111',
create_date: '2023-05-14 12:19:19' },
{ _id: '6460d1e8819ce8deee50172a',
name: '222',
description: '22222',
create_date: '2023-05-14 12:19:52' } ]
}
【报Bug】云对象查询数据库,get里面添加getCount, 不能返回正常的Count总数,但是在JQL查询示例里面,可以返回正常的数据字段 count。两者返回的数据不一样。新增的云对象,确认加入库了。"extensions": { "uni-cloud-jql": {} }
用的云对象 URL方式。
呆狗的一生 - 呆狗的一生
试试把db改成下面的:
const dbJQL = uniCloud.databaseForJQL({ // 获取JQL database引用,此处需要传入云函数的event和context,必传
event,
context
})
l***@163.com (作者)
回复 呆狗的一生: 我用的云对象。这样写就ok了。谢谢啦
const dbJQL = uniCloud.databaseForJQL({
clientInfo: this.getClientInfo()
})
const res = await dbJQL.collection('news-categories').skip(skip).limit(limit).orderBy('update_date', 'desc')
.get({
getCount: true
})
2023-05-14 21:57
l***@163.com (作者)
已经加上了
2023-05-14 21:24