云开发的Collection.field的数组截取不起作用?
发布于 6 年前 作者 fangyao 7336 次浏览 来自 官方Issues
const db = wx.cloud.database()db.collection('todos').field({
  description: true,
  done: true,
  progress: true,
  // 只返回 tags 数组前 3 个元素
  tags: db.command.project.slice(3),})
  .get()
  .then(console.log)
  .catch(console.error)

2.8.3版本查询使用该命令就会报错

tags: db.command.project.slice(3)

改成true的话就没有问题

tags: true

文档位置:https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-client-api/database/collection.field.html

回到顶部