Introduction to WeChat Small Program Cloud Database

WeChat small program cloud development detailed tutorial?

Developers can use cloud development to develop WeChat small programs, small games, without the need to build servers, you can use the cloud capabilities. (The cloud is frankly the server la, said so lofty, not too friendly to new friends.)

Small program-cloud development provides three basic capabilities: database, storage and cloud functions.

Database: json database, it is understood that to store inside is json, take out is also json.

Storage: is to put your picture, audio and video and other resources such as files, stored in it, to help you generate links, directly take the link can be used, just like a network disk.

Cloud function: this cloud function, that is, the server-side interface, you call this function, that is, call the interface. Cloud function can be written in the client , you can also write in the cloud development console , after writing a synchronization , both ends will have. In the cloud function, you can perform calculations or manipulate the database, returning the desired result to the client in a synchronized or asynchronous manner.

This is not the case with normal development, which requires preparation for all of the above. So, cloud development is much more convenient and efficient than normal development.

Limitations of WeChat applet cloud database

Slow product launch.

Small program cloud data is a native serverless cloud service integrated into the small program console. Core features include: cloud storage, cloud database and cloud functions. Small program cloud development solves the problems of low development efficiency, high resource investment, slow product on-line and difficult daily operation and maintenance in the traditional development mode. In the traditional development mode, the developer needs to request the back-end from the small program side through the additional references to the SDK, and needs to be concerned about elasticity and scalability, offsite disaster recovery, network protection, security reinforcement and many other conditions. Too much business logic needs to be handled, resulting in low development efficiency.

What are the WeChat small program mall class databases

WeChat small program mall class databases include:

1, the user information table, used to store the user’s basic information, such as user name, cell phone number, password, avatar and so on.

2, commodity information table, used to store the basic information of the commodity, such as product name, price, description, pictures and so on.

3, order information table, used to store the basic information of the order, such as order number, the user who placed the order, product information, price, etc..

4, the delivery address table, used to store the user’s delivery address information, such as the name of the consignee, delivery address, contact phone number and so on.

5, commodity classification table, used to store the basic information of commodity classification, such as classification name, classification picture and so on.

6, commodity attribute table, used to store the basic information of commodity attributes, such as attribute name, attribute value and so on.

7, shopping cart table, used to store the user shopping cart information, such as user ID, product ID, the number of products.

8, Coupon table, used to store coupon information, such as coupon type, discount price and so on.

9, evaluation table, used to store product evaluation information, such as evaluation content, rating and so on.

WeChat small program how to use the cloud development

WeChat small program in the cloud development must not be very familiar with the cloud development, because the cloud development is also on-line in September, compared to the previous everyone for the storage of the database are used is their own servers, the next article mainly for you to introduce how to use the cloud development, the Internet has seen a lot of articles feel that the introduction of not very detailed, the following through my personal experience to organize their own ideas The next article is about how to use the cloud development, there are many articles on the Internet that are not very detailed, the following through my personal experience to organize their own ideas.

First of all, the cloud development of the three main features, currently provides three basic capabilities to support:

Cloud function: the code running in the cloud, WeChat private protocols natural authentication, the developer only need to write their own business logic code

Database: a small program can be operated in the front-end, but also in the cloud function to read and write JSON database

Storage: directly upload/download cloud files in the front-end of the small program, visual management in the cloud development console

To put it bluntly, the cloud function is the back-end code, now called the cloud function, write your own, upload your own, the database is nothing to talk about is the database, but this database is a json database, it’s very easy to use, for example, we use MySQL to create a database not only need to write the database name, build a table also need to design field types more painful is that they also need to write some code to connect to the database, on the contrary, the cloud development is more simple, you just need to build a collection inside (also known as the table name), and then fill in the name of your own fields to choose the appropriate type can be as follows:

Well, we get back to the point, say the specific steps are as follows

1, open one of our own project and then click on the cloud development above

2, then you need to create a new environment, where the variables to fill in their own can be as follows

3, create a good we will be out of the first as shown below


WeChat small program with what database

WeChat small program with the following way to configure the database: server and your local development environment are well configured tomcat and php. wechat public number above is through his event to trigger your background methods, so you event triggered by the method inside the writing of the corresponding logic code. Connect to the database on the standard connection, if you do not use the framework of the case. URL and token as long as the WeChat server and your own server to connect to a good after the basic do not need to use, you can refer to the official sample.php file. call data code, if you do not use the framework, of course, you can only use the original mysqli_query($conn,$sql.