微信小程序添加数据到数据库中

在一个事件函数中 

//stu是一个数据库的名称

const db = wx.cloud.database() 

const stu =  db.collection('student')

//添加一个data数据到stu数据库中

stu.add({

      data:{

//获取输入的内容

        name: this.data.name,

        age: parseInt(this.data.age),

        sex: this.data.sex

      }

    }).then(res=>{

      console.log(res)

    }).catch(err=>{

      console.log(err)

    })

个人之见,勿喷!

你可能感兴趣的:(big,data,小程序,html5)