Collection.watch / Query.watch 文档错误

发布于 6 年前作者 shenchao11728 次浏览最后编辑 6 年前来自 issues
const db = wx.cloud.database()
const watcher = db.collection('todos').where({
  _openid: 'xxx' // 填入当前用户 openid
}).watch({
  onChange: (res) => {
    console.log(res.data)
  },
  onError: (err) => {
    console.error(err)
  }
})

打印的res没有data字段,为undefined

3 回复
ilai
ilai1 楼6 年前

这个错?

zhengjuan
zhengjuan2 楼6 年前

不好意思,是 API 文档示例错误,是有这几个字段。请看https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/realtime.html

liduan
liduan3 楼5 年前

改成云函数执行。