FinClip cloud development practice (with small program demo)

When developing a small program, in addition to considering the logic of interface functions, back-end data support is also required. Developers need to consider the support capabilities of servers, storage, and databases in advance. In addition, they may need to spend time and energy on deploying applications, and Depends on the construction of the service.

Therefore, in order to realize the rapid launch and iteration of small programs, Tencent provides developers with a cloud development function. It will provide developers with required functions such as cloud functions, cloud databases, and storage management in the form of services. The development threshold of small programs is lowered.

Wait, what are these three functions?

1. What is a cloud function?

A cloud function is a function that runs on the cloud (server side). In terms of physical design, a cloud function can be composed of multiple files, occupying a certain amount of computing resources such as CPU memory; each cloud function is completely independent; it can be deployed in different regions. Developers do not need to buy or build servers, they only need to write function codes and deploy them to the cloud to be called on the applet side, and cloud functions can also call each other.

Cloud function is equivalent to the back-end code in the traditional front-end and back-end separate development. It runs on the server, reads and writes to the database faster, and can handle more complex calculations. A cloud function is written in the same way as a JavaScript method defined locally, and the code runs in Node.js in the cloud.

2. What is a cloud database?

Cloud Development provides a JSON database. As the name suggests, each record in the database is an object in JSON format. A database can have multiple collections (equivalent to tables in relational data), and a collection can be regarded as a JSON array. Each object in the array is a record, and the format of the record is a JSON object.

3. What is cloud storage?

Cloud development provides a storage space, uploading files to the cloud, and cloud download capabilities with permission management. Developers can use cloud storage functions through APIs on the applet side and cloud function side.

In the latest version of the FinClip product, we have realized the support for the relevant capabilities of the mini program for "Tencent Cloud" cloud development. Come and see how to use it.

Introduction

To use the cloud development capability of "Tencent Cloud" in the  FinClip applet , the following prerequisites need to be noted:

You can click the above link to view details, or follow this article, we will show you how to use cloud development in applets through a DEMO .

The first step is to open the WeChat applet cloud development capability

​When creating a Mini Program in WeChat, you can select "WeChat Cloud Development" in the backend service, and after creating the Mini Program, click the "Cloud Development" button in the upper left corner to activate it.

New users can use the basic package of WeChat Mini Program Cloud for one month for free, and then they can pay according to the amount of the basic package of 19.9 yuan/month. Click here for details .

After the creation is complete, you can click the "Cloud Development" button again, and you can see the created cloud function, cloud database and cloud storage related resources on the newly opened page. We can directly click on the "Database" at the top and create the corresponding data collection in it.

The second step is to use the applet DEMO to call the cloud function

Our R&D classmates wrote a small program DEMO that invokes cloud development capabilities. You can click the link below to get resources.

This is the small program DEMO  miniprogram cloud.zip we  wrote. After downloading, use FinClip Builder to open the small program file, and then edit and replace the corresponding AppID, Secret and environment variable information in "index.js".

As shown in the figure above, after we replace the content in the index.js file with the AppID of our own WeChat applet, Secret and the environment ID of the cloud development capability, we can directly click the relevant button in the left window, and the button will Print out the corresponding result in the console at the bottom.

For example, we inserted a piece of data like this into the database:

​Then you can query this piece of data in the cloud database according to the "data collection name" and "id":

postscript

The above content is only for demonstration. In actual use, we need to use the cloud development capabilities reasonably based on the content and architecture design of the applet. If you are still interested in cloud development, you can also take a look at these cloud development applets recommended by Tencent Cloud . sample , and try using Browse in the FinClip environment.

Guess you like

Origin blog.csdn.net/finogeeks/article/details/130072809