const db= wx.cloud.database()
Page({
onchick:function(){
var mt=19
db.collection("time").where({ //查询time云数据库
htime: mt
})
.get()
.then(res=>{
console.log(res);
var tim=res.data[0].time; //得到 tim
db.collection("timeone").add({ //写入timeone云数据库
data: {
htimone:tim,
htim2:0,
},
success(res) {
console.log("添加成功", res)
},
fail(res) {
console.log("添加失败", res)
}
})
db.collection("timeone").where({ //查询数据库
htim: (tim)
})
.get()
.then(res => {
console.log(res);
var tmid = res.data[0]._id; //查询出id
var tim2=tim+1;
db.collection("time").where({ //查询
bhtime:(tim2)
})
.get()
.then(res=>{
console.log(res);
var tim3=res.data[0].time; //得到tim3
db.collection("timeone").doc(tmid).update({ //更新云数据库记录
data: {
htim2:tim3
},
success: res => {
console.log('成功', res.data)
}
})
});
})
})
}
})
你坚持一下数据库授权