| 12345678910111213141516171819202122232425262728293031323334353637 |
- // 云函数入口文件
- const cloud = require('wx-server-sdk')
- cloud.init()
- const db = cloud.database()
- // 云函数入口函数
- exports.main = async (event, context) => {
- const {
- OPENID
- } = cloud.getWXContext()
- const follow_check = await db.collection('follow')
- .where({
- user_id: OPENID,
- pub_id: event.pub_id || ''
- })
- .get()
- if (follow_check.data.length === 0) {
- return {
- errMsg: '社团组织不存在',
- status: 'ERR'
- }
- }
- const follow = await db.collection('follow')
- .where({
- user_id: OPENID,
- pub_id: event.pub_id
- })
- .remove()
- return {
- stats: follow.stats,
- status: 'OK'
- }
- }
|