<template>
<view class="content">
<view> <button @click="add()">增</button> </view>
<view> <button @click="shan()">删</button> </view>
<view> <button @click="shanx()">删x</button> </view>
<view> <button @click="gai()">改</button> </view>
<view> <button @click="gaix()">改x</button> </view>
<view> <button @click="cha()">查</button> </view>
<view> <button @click="chax()">查x</button> </view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {
wx.cloud.init({
env:'输入自己的云开发环境ID"
})
},
methods: {
add(){
const db = wx.cloud.database();
db.collection('score').add({
data:{
description:'niu',
}
})
.then(res=>{
console.log(res)
})
},
shan(){
const db = wx.cloud.database();
db.collection('score').doc('bf4a0bf261e17e26065c80b8006d6444').remove().then(res=>{
console.log(res)
})
},
shanx(){
const db = wx.cloud.database();
db.collection('score').where({
_id: '17e3426e61e17d0506636dbf166eb555'
}).remove().then(res=>{
console.log(res,'remove多条删除')
})
},
gai(){
const db = wx.cloud.database();
db.collection('score').where({
_id: '287a53aa61ae21dc00c2da654d9653ff'
}).update().then(res=>{
console.log(res,'remove多条删除')
})
},
gaix(){
const db = wx.cloud.database();
db.collection('score').doc('54ad1eea61e1927d071ac648503d24e1').update({
data:{
description:'08',
}
}).then(res=>{
console.log(res)
})
},
cha(){
const db = wx.cloud.database();
db.collection('score').doc('287a53aa61ae21dc00c2da654d9653ff').get().then(res => {
console.log(res.data)
})
},
chax(){
const db = wx.cloud.database();
db.collection('score').where({
_openid: 'oAgIh4z4-PR4Ro_sN6Qde2bIhWGQ'
}).get({
success: function(res) {
console.log(res.data)
}
})
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>