云数据库不更新
发布于 5 年前 作者 achang 1833 次浏览 来自 问答

arrived: function(e) {

var index = e.currentTarget.dataset.index

if (this.data.topIndex == 0) { //若是主队

this.data.homeTeamPlayer[index].arrived = !this.data.homeTeamPlayer[index].arrived

this.setData({

homeTeamPlayer: this.data.homeTeamPlayer

})

console.log(this.data.homeTeamPlayer)

wx.cloud.callFunction({ //调用数据库修改数据

name: ‘teamUpdate’,

data: {

homeTeam: this.data.homeTeam,

homeTeamPlayer: this.data.homeTeamPlayer

},

success: res => {

console.log(res)

}

})

} else {

this.data.visitTeamPlayer[index].arrived = !this.data.visitTeamPlayer[index].arrived

this.setData({

visitTeamPlayer: this.data.visitTeamPlayer

})

}

},

这是小程序页面homeTeamPlayer更改后调用云函数修改数据库

// 云函数入口文件

const cloud = require(‘wx-server-sdk’)

cloud.init()

const db = cloud.database()

// 云函数入口函数

exports.main = async(event, context) => {

console.log(event.homeTeam)

console.log(event.homeTeamPlayer)

return await db.collection(‘teams’).where({

teamName: event.homeTeam

})

.update({

data: {

teamPlayers: event.homeTeamPlayer

},

})

}

这是云函数

为啥更新不了啊,而且返回结果也没有stas{update:1}这样的res

求解呀

回到顶部