//=========================下面代码在云对象中获取到为{}空
let currentUid = "0";
const dbJQL = uniCloud.databaseForJQL()
dbJQL.setUser({
uid: currentUid,
role: ['admin'],
})
let queryInfo = dbJQL.collection('chat-message').aggregate()
.sort("create_date, ase")
// .group({
// _id: "$roomId",
// message: dbJQL.command.aggregate.first('$message'),
// state: dbJQL.command.aggregate.first('$state'),
// sendUid: dbJQL.command.aggregate.first('$sendUid'),
// sendNickName: dbJQL.command.aggregate.first('$sendNickName'),
// lastMessageDate: dbJQL.command.aggregate.first('$create_date')
// })
.limit(20)
.end()
console.log("queryInfo:"+JSON.stringify(queryInfo))
// ===========================下面代码在jql中可以获取到数据两条。
db.collection('chat-message').aggregate()
.sort("create_date, ase")
// .group({
// _id: "$roomId",
// message: db.command.aggregate.first('$message'),
// state: db.command.aggregate.first('$state'),
// sendUid: db.command.aggregate.first('$sendUid'),
// sendNickName: db.command.aggregate.first('$sendNickName'),
// lastMessageDate: db.command.aggregate.first('$create_date')
// })
.limit(20)
.end()
1 个回复
newPage (作者)
可以关闭了,少了一个await导致的