

English
uniCloud
is a cloud development platform based on serverless mode and js programming provided by DCloud and Alibaba Cloud and Tencent Cloud for developers.
uniCloud
web console address: https://unicloud.dcloud.net.cn
uniCloud provides a free service space for each developer, so that you can also have your own server.
uniCloud is a package of DCloud on the serverless services of Alibaba Cloud and Tencent Cloud.
It consists of IaaS layer (hardware and network provided by Alibaba Cloud and Tencent Cloud) and PaaS layer (development environment provided by DCloud).
Developers can independently choose the supplier of uniCloud hardware and network resources, and switch between Alibaba Cloud Edition and Tencent Cloud Edition.
Although account opening and payment are made through the DCloud channel, in fact, the developer automatically establishes an account and recharges the balance at the cloud vendor. The price is the standard pricing of cloud vendors, and DCloud only gets rebates from cloud service vendors.
Although DCloud's tools are used during development, when the application is launched, the mobile terminal is directly connected to Alibaba Cloud or Tencent Cloud's serverless, without going through DCloud's server.
Serverless is a very popular concept at present. It is the next generation cloud technology and a real "cloud".
Traditional cloud services free developers from purchasing physical server hardware and instead purchase virtual machines. However, developers still have to install their own operating systems, web servers, and databases, handle hot backup by themselves, purchase new servers to deal with high concurrency, and resist DDOS attacks by themselves...
This is not a full-fledged "cloud"!
True cloud computing is like using electricity and water. There are no complicated thresholds. It is available and paid on demand.
Briefly review the history of electricity consumption. A few decades ago, many units had engineers specializing in power management. When the power load of the unit was not enough, it was necessary to find this engineer to expand the generator capacity.
Now the post of electrical engineer has been eliminated, and electricity has become on-demand and pay-as-you-go.
In the traditional cloud model, developers still need an engineer to manage the server. When the number of users surges or is attacked, they even need to wake up the engineer in the middle of the night to expand the capacity. This is of course unreasonable.
The serverless cloud truly cloudifies the computing and storage capabilities. Developers only need to rent these computing and storage capabilities according to the amount, and no longer need to worry about expansion and attacks.
Developers no longer have the concept of a "server" because there is no specific machine. Just like now you can't find your own generator anymore.
When the number of users surges, developers don't have to do anything, and the system automatically carries higher concurrency. Developers only need to pay according to the consumption of resources.
Similarly, if there is no user usage, that is, no resource consumption, there is no need to pay for cloud resources at all.
Developers write cloud business code, that is, cloud functions written in js, and deploy them to uniCloud through HBuilderX.
The huge serverless resource pool in the cloud has countless node processes on standby. When a mobile phone user initiates a request, the serverless system will allocate idle resources to run the developer's corresponding cloud function.
Serverless is emerging in foreign countries, but the domestic development speed has surpassed that of foreign countries. WeChat, Alipay, Baidu, ByteDance, and Kuaishou Alliance have all launched their own serverless cloud development.
At present, more than 600,000 developers in China are using serverless cloud development, including many self-owned businesses of Tencent, Alibaba, and DCloud.
Just like uni-app can be cross-end, uniCloud can be cross-cloud. Based on uniCloud, there is no need to worry about using cloud development to be bound to a dedicated applet platform. uni-app + uniCloud is a cross-end and cross-cloud development solution.
**1. The lease of traditional cloud services is based on the upper limit of the occupied hardware resources + a fixed duration. **
The traditional cloud is to buy servers according to the configuration, and after buying, you have to pay whether you use it or not. And serverless is billed by volume, if you don't use it, you don't have to pay a penny.
The traditional cloud chooses the configuration of CPU and memory. When the configuration is less than full, resources are wasted. When it is close to full configuration, a new configuration needs to be expanded immediately.
Serverless is not a traditional cloud, it does not require developers to choose CPU and memory configuration, and there is no choice of operating system. The developer writes the cloud function code and uploads it to the Alibaba Cloud version or Tencent Cloud version of uniCloud.
Alibaba Cloud and Tencent Cloud have built a huge serverless resource pool, and many node processes are used to run cloud functions.
These resources are reused and shared. There is no one developer who rents 3G CPU and 8G memory, and these hardware can only be used by him.
Because of sharing a large resource pool, the cost of cloud service providers is greatly reduced, and developers do not need to pay for idle resources, and cloud functions are only billed when they are called.
From a technical point of view, serverless has obvious cost advantages, so renting serverless is much cheaper than renting traditional cloud.
2. There are no numerous charging items
In the world of traditional cloud, there are a plethora of premium offerings.
On the official websites of Alibaba Cloud and Tencent Cloud, you can see a long list of paid products, such as load balancing, high defense, CDN back-to-source, security center...
This billing item is expensive and makes developers dizzy. In the world of uniCloud, it is simple and clear, there are no such fees.
You only need to pay for the consumption of computing resources and storage resources, you only need to care about the business, and you don't need to care about other value-added products in various names, and you don't need to pay for them.
You must know that a high-defense package for anti-DDoS is at least tens of thousands of yuan per month. And these fees do not need to be paid in uniCloud.
Let's talk about why uniCloud does not need to buy high defense and is not afraid of DDoS: Because Alibaba Cloud and Tencent Cloud's serverless have huge resource pools, and serverless does not have a fixed IP, cloud functions use Alibaba Cloud and Tencent Cloud's own domain names, front-end Web pages are hosted on CDNs, and DDoS attackers can't fight or hang up uniCloud.
3. Subsidy discounts for cloud vendors
uniCloud Alibaba Cloud Edition provides one free service space for each developer. Traditional clouds don't have this perk.
4、DCloud的议价能力
DCloud拥有国内广泛的开发者,可以与云厂商谈判拿到非常低的价格。所以不管是服务器计算资源、还是短信、实人认证、一键登陆等云能力,uniCloud里的定价均低于阿里腾讯等云厂商的定价。
基于以上4点原因,uniCloud大幅降低了开发者云资源的租用成本。
In addition to the cost of cloud resources, uniCloud can also reduce the labor cost, recruitment cost, and communication management cost of developers, which are far greater than the cost of cloud resources.
Front-end engineers want to master back-end development, there are 6 major barriers:
With uniCloud, these thresholds are all lowered:
So, uniCloud is the best opportunity for the front-end to become a full-stack. Just spend some time reading the uniCloud documentation, and you can become a full-stack!
The most attractive thing about uniCloud is that it improves development efficiency by more than 10 times.
In the three years since uniCloud was launched, uni-app + uniCloud has become a huge ecosystem. Including a lot of tools, modules.
The 10-fold increase in development efficiency is not due to a certain killer function, but the common effect of a huge ecosystem. This chapter is long, please read it with patience.
At the beginning of 2020, uniCloud was just released, the new crown pneumonia suddenly hit, and a large number of anti-epidemic projects emerged in various places.
uni-app + uniCloud has become an important tool for everyone and viruses to grab time.
Hundreds of anti-epidemic projects based on the uni system have sprung up everywhere. For details, see: https://www.dcloud.io/ncp.html
At that time, the development of an anti-epidemic project still required dozens of man-days.
Taking the project of Access Management Registration as an example, the first version was done for 10 days, and 4-5 full-time or part-time engineers participated.
One year later, in the Spring Festival of 2021, the demand for returnees information registration appeared in large numbers in various places.
The project requirements are similar, but the uniCloud ecological construction has been completed at this time. Based on various tools, the number of developer days for the returnee registration system has been greatly reduced, and it only costs 0.0625 person-days!
In one year, the development efficiency has increased by nearly 1000 times!
There is too much content in the uni cloud integrated ecology. Let us take a look at it, summarize and classify it, and explain how to improve the development efficiency in an easy-to-understand way.
Development efficiency is improved, divided into 8 levels:
Let's expand on each layer in turn.
This is the most easily understood value in the cloud-integrated ecosystem: a large number of open source modules.
In the previous open source modules, the basic end is the end, the cloud is the cloud, and I have never heard of an open source module that integrates the cloud.
Taking the user module as an example, it actually has a front end and a cloud. The front end has pages for registration, login, and password modification, and the cloud has corresponding logic codes and databases.
Now there is uni-id, an open source, full-featured, cloud-integrated user module. Instantly save man-months of development effort.
Listed below are some commonly used wheels
1. Officially maintained plugins
2. Excellent plugins from the community
3. Project Template
The wheel above is a general-purpose wheel that has nothing to do with business. In addition, there are a large number of cloud-integrated project templates. Using these ready-made project templates, the development efficiency is greatly improved. Projects that took 5 or 6 person-months in the past can now be launched in a few days!
E-commerce | Blog | Scheduling |
Net Earning Synthetic Game | Social | Reservation |
O2O | Short Video | Family Tree |
Takeaway | Music | Avatar Pendant |
Film | Accounting | Portrait Cutout, Comic Face |
News | Attendance punch card | Red envelope cover |
Here we also have to mention 2 new concepts: uni_module
and datacom
.
Excellent modular solutions make the ecology more and more prosperous.
If you can't find a ready-made wheel in the first layer of efficiency improvement, you need to write your own code. So the first thing to do is to use the artifact schema2code to automatically generate code.
The schema of uniCloud cloud data is an important innovation. Writing a schema for a data table can achieve very many functions: data structure definition, permission management, data range management, and very magical functions -- "schema2code"
In traditional development, with the database, the crud background interface can be generated. Then the front end writes code to call the interface.
However, in the uni cloud-integrated ecosystem, with the schema of the database, a cloud-integrated page can be generated directly. Instead of just generating just the interface.
schema2code, can generate the list, details or add, delete and modify pages on the mobile phone, and can also generate pages for all data management functions on the admin management side.
The following is the operation demonstration video of schema2code:
You can actually experience this project of Cloud Integration Address Book, and almost no code is written alone. After designing the table schema of the address book, use schema2code to generate this project.
The above-mentioned management project for returnees can be completed in only half an hour, which is also the credit of schema2code.
Data rights management is also very simple. In the schema, you can quickly define the specified data records or fields, which can only be operated by people with what roles or rights.
The range verification of data storage is simpler. In traditional development, the verification of a mobile phone number needs to be written on the front-end page and checked again before the server is stored, which is redundant. Now that the cloud is coordinated, this problem will naturally be optimized.
Now you only need to define the optional value field of the mobile phone number field in the DB Schema, such as a regular, then schema2code will automatically generate the front-end form, and follow the definition of the schema, only accept the same regular.
This not only improves development efficiency, but also avoids various loopholes in traditional development and maintains rigor and consistency.
The code generated by schema2code is clear and easy to read and easy for secondary development. This is more efficient than low-code platforms, and is completely open and open source, free to expand.
If schema2code still cannot meet your needs and needs to be developed separately, as long as you operate the database, clientDB is the recommended tool.
In traditional development, the front-end writes requests for networking, the back-end writes and receives requests to check the database, returns them to the front-end, and then binds the data to the front-end... Isn't it annoying to do such a boring thing every day?
uni-app provides the <unicloud-db>
component (the trigger key of the code block is udb), which directly accesses the database on the front end, which is unprecedentedly efficient and concise, and does not need to write server code in most scenarios!
For example, the cloud database of uniCloud has a user table, which contains fields id and name, query the user data with id=1, and display the name on the interface, which is written as follows:
<template>
<view>
<unicloud-db v-slot:default="{data, loading, error, options}" collection="user" field="name" :getone="true" where="id=='1'">
<view>
{{ data.name}}
</view>
</unicloud-db>
</view>
</template>
Yes, with only 5 lines of code, it is possible to complete what used to be done by writing dozens of lines of code in the front and back ends, and the amount of code is greatly reduced to one-tenth of the original.
There is no need to worry that the front-end directly accessing the database will cause security risks. The DB Schema was mentioned in the previous section. In the schema of the cloud, you can define what roles can operate the database. See details
The clientDB technology includes front-end JS API and [front-end components] (unicloud-db.md). In order to further improve development efficiency, clientDB also provides several major tools: JQL is a js-based database manipulation language, which improves many inconveniences of SQL language.
It can be seen that in the uni cloud integrated ecosystem, developers not only improve efficiency and reduce costs, but also get more powerful enabling tools.
If clientDB still cannot meet the requirements and must write cloud code, the emergence of cloud object has completely changed the inefficient situation of back-end development of json interface and front-end joint debugging.
Cloud Object Change the code in the cloud into an object method, let the front-end js directly import this object, and then use the method of this object, just like using the front-end js object.
Add a todo
cloud object to the cloud, write an add method, the code is as follows:
// Cloud object name: todo
module.exports = {
add(title, content) {
title = title.trim()
content = content.trim()
if(!title || !content) {
return {
errCode: 'INVALID_TODO',
errMsg: 'TODO标题或内容不可为空'
}
}
// ...other logic
return {
errCode: 0,
errMsg: '创建成功'
}
}
}
Then in the client-side js, import the todo
object and call its add method
const todo = uniCloud.importObject('todo') //第一步导入云对象
async function addTodo () {
try {
const res = await todo.add('title demo', 'content demo') //导入云对象后就可以直接调用该对象的方法了,注意使用异步await
console.log("add成功")
} catch (e) {
// Compliant with uniCloud response body specification https://uniapp.dcloud.net.cn/uniCloud/cf-functions?id=resformat, this error will be thrown automatically
console.log(e.errMsg)
}
}
HBuilderX, uni-app, and uniCloud are trinity and efficient collaboration.
HBuilderX improves the development efficiency of uni-app, and will naturally improve the development efficiency of uniCloud. And the Trinity has achieved new breakthroughs that were previously unimaginable.
The following figure is an example:
In traditional development, item is a json returned by request, and it is impossible for IDE to know the data structure of this json, so it cannot prompt.
The methods of cloud objects can also be perfectly parsed by HBuilderX, so that the methods and parameters of cloud objects can be directly prompted when writing client code.
Both the front-end and the cloud use the js programming language, which improves communication efficiency.
js and other server languages, such as php or java, used Mock to translate, which was redundant.
In actual development, developers should arrange personnel to divide labor according to business and focus on business. One person is responsible for the front-end and back-end of a business module. Development efficiency will be higher than before.
Due to the unified technology stack, recruitment efficiency and management efficiency will also be improved accordingly. .
The amount of code is reduced to one-tenth of the original, which naturally increases the efficiency of code review and white-box testing tenfold.
In black-box testing, the probability of occurrence of bugs and permission loopholes with front and back ends being misaligned is also greatly reduced.
Now, development and testing will become easier.
Because of the free operation and maintenance feature of serverless, developers no longer have to worry about a series of troubles such as capacity expansion, high concurrency, ddos attacks, and security vulnerability patches. Just focus on your business.
uniCloud is a revolution in the development world. With the cooperation of HBuilderX, uni-app, and uniCloud, innovative functional design, rich ecology and wheel support, the development efficiency of developers is more than 10 times that of traditional development.
At present, uniCloud has been developed for more than 3 years, with tens of thousands of active service spaces and over 100 million cloud function requests per day. Please use it with confidence.