FinClip|What about the cloud development of small programs

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.
insert image description here
Therefore, in order to realize the rapid launch and iteration of small programs, WeChat Mini Program provides developers with a cloud development function, which will provide developers with required functions such as cloud functions, cloud databases, storage management, etc. in the form of services, greatly greatly The development threshold of small programs is lowered.

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, the applet has realized the relevant capability support for "Tencent Cloud" cloud development, let's 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 need to have enabled the cloud development capability of the Mini Program;
you need to configure the AppID, Secret and cloud development environment ID of the WeChat Mini Program in the code;
you can follow the documentation center to demonstrate how to use cloud development in the Mini Program through a DEMO.

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

When creating a small program in WeChat, you can select "WeChat Cloud Development" in the back-end service, and after creating the small program, click the "Cloud Development" button in the upper left corner to activate it.

insert image description here

New users can use the basic package of WeChat Mini Program Cloud for one month for free.
insert image description here

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

The official wrote a small program DEMO that invokes cloud development capabilities.

Use FinClip Builder to open this applet file, and then edit and replace the corresponding AppID, Secret and environment variable information in "index.js",
insert image description here

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:
insert image description here

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

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/POHOU23/article/details/130127397