当前位置:首页 > 微信 > 正文

前端随心记---------小程序的云函数

11-26 微信

标签:update   ESS   sea   inf   mamicode   data   增删改查   delete   pre   

小程序的云函数开发:

技术图片

 

 

技术图片

 

 

 

技术图片

 

 技术图片

 

 技术图片

开启小程序的云开发模式:

当每次添加新的函数时,都需要手动进行上传,需支持npm时要在项目开启nom支持。

云函数的增删改查:

增:

insert: function () {
    db.collection(‘user‘).add({
      data: {
        name: ‘may‘,
        age: 18
      },
      success: res => {
        console.log(res);
      },
      fail: err => {
        console.log(err);
      }
    })
  },

改:

  updata:function(){
    db.collection(‘user‘).doc(‘137264b55db292b30067d7b716f48bd9‘).update({
      data:{
        age:21
      }
    }).then(res => {
      console.log(res)
    }).catch(err => {
      console.log(err);
    })

  },

查:

search:function(){
    db.collection(‘user‘).where({
      age:21

    }).get().then(res => {
      console.log(res);
    }).catch(err =>{
      console.log(err);
    });
  },

删:

 delete:function(){
    db.collection(‘user‘).doc(‘137264b55db292b30067d7b716f48bd9‘).remove().then(res =>{
      console.log(res);
    }).catch(err =>{
      console.log(err);
    })
  },

求和:

 sum:function(){
    wx.cloud.callFunction({
      name:‘sum‘,   云函数名
      data:{
        a:2,
        b:3
      }
    }).then(res => {
      console.log(res)
    }).catch(err => {
      console.log(err)
    })
  },

 

 

 技术图片

 

前端随心记---------小程序的云函数

标签:update   ESS   sea   inf   mamicode   data   增删改查   delete   pre   

温馨提示: 本文由杰米博客推荐,转载请保留链接: https://www.jmwww.net/weixin/15898.html

博客主人杰米WWW
杰米博客,为大家提供seo以及it方面技巧喜欢的朋友收藏哦!
  • 11365文章总数
  • 2266822访问次数
  • 建站天数
  • 头条文章

    图文推荐

    站长推荐

    友情链接