WeChat Mini Program - Start of Cloud Development

Article Directory

foreword

1. Quick start

2. Cloud development in practice

1. Enable cloud development

2. Configure the current cloud development environment

3. Understand the directory structure

4. Cloud function operation process

5. Upload the cloud function to the cloud service

6. Basic operations (add, delete, modify, check)

Summarize

 

foreword

 WeChat applet cloud development:

             1. No need to build a server, just use the various capabilities provided by the platform to quickly develop business.

              2. There is no need to manage certificates, signatures, and secret keys, and directly call the WeChat API. Reuse WeChat private protocols and links to ensure business security. 

              3. Support environment sharing. One back-end environment can develop multiple small programs, official accounts, web pages, etc., and reuse business codes and data conveniently.

               4. Support pay-as-you-go mode, the back-end resources are automatically expanded according to the business traffic, use it first and then pay, without paying idle costs.


提示:以下是本篇文章正文内容,下面案例可供参考

1. Quick start

           Preparations: If you are using the WeChat Mini Program for the first time, you must    click to view

                             Including the account registration application, the creation process of WeChat applet cloud development, etc. (skip here);

2. Cloud development in practice

1. Enable cloud development

 Open cloud environment

2. Configure the current cloud development environment

3. Understand the directory structure

    Understand the file directory

4. Cloud function operation process

Cloud function main entrance

 Cloud functions operate on databases

 Local code calls cloud functions

5. Upload the cloud function to the cloud service

 1. Deploy cloud functions

 2. Upload and update the cloud function ( if you modify the cloud function, you must remember to update )

 

6. Basic operations (add, delete, modify, check)

const cloud = require('wx-server-sdk') //引入微信及sdk

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV //配置默认开发环境
})

const db = cloud.database() //链接数据库
name the code
Add
db.collection('表明').add({
  // data 字段表示需新增的 JSON 数据
  data: { 
    xxxxx:xxxxxx,
    xxxxx:xxxxx
  }
})
.then(res => {
  console.log(res)
},err=> {
  console.log(err)
})
delete
 db.collection('表名').where({
      xxx: xxx//条件
    }).remove().then(res => {
  console.log(res)
},err=> {
  console.log(err)
})
Revise
db.collection('表名').where({
      xxx:  xxx
    })
    .update({
      data: {
         xxx:  xxx
      }
    }).then(res => {
  console.log(res)
},err=> {
  console.log(err)
})
Inquire
db.collection('表名').where({
  xxx: xxx,
  xxx: xxx
})
.get().then(res => {
  console.log(res)
},err=> {
  console.log(err)
})

 


Summarize

 WeChat applet cloud development: it is convenient, fast, time-saving, labor-saving and money-saving for small projects; it is recommended not to use the cloud development model for large-scale projects;

Be sure to read the WeChat applet cloud development document cloud development document address icon-default.png?t=M85Bhttps://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html

demo download address icon-default.png?t=M85Bhttps://gitcode.net/weixin_41620505/wechat_cloud

Guess you like

Origin blog.csdn.net/weixin_41620505/article/details/126781494