受欢迎的博客标签

微信小程序云开发-云端集合自定义安全规则(crud)

Published

https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/security-rules.html#%E7%A4%BA%E4%BE%8B-2%EF%BC%9A%E4%BF%A1%E6%81%AF%E6%B5%81%E8%AF%84%E8%AE%BA

 "read": true, // 公有读
  "create": "doc.publisher == auth.openid", // 都可以发文章,但对数据一致性校验,要求 publisher 为发布者 openid
  "update": "doc.publisher == auth.openid || get('database.user.${auth.openid}').isManager", // 仅发布者或管理员可以更新
  "delete": "doc.publisher == auth.openid || get('database.user.${auth.openid}').isManager", // 仅发布者或管理员可以删除

用云函数创建的记录,设置下面的权限,微信客户端可读写

将read 和write均改为true
所有用户可读 “read”:true
所有用户可写"write":true

{
  "read": true,
  "write": true,
}