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 value

  • For programmers, from now on, you can get a new skill, and use the familiar js to easily handle the overall business of the front and back.
  • For developers:
    1. The development cost has been greatly reduced, the development efficiency has been greatly improved, and the launch and iteration speed has been greatly accelerated;
    2. If you are a start-up company, you will not need to hire server engineers such as php or java, saving at least hundreds of thousands every year;
    3. If you already have a full stack of php and js, then switching to a new technology stack can greatly improve development efficiency and reduce costs;
    4. You only need to focus on your business, and you don't need to worry about other server operation and maintenance, elastic expansion, large concurrent load, and anti-DDoS attack;
    5. In addition to development costs, cloud resource rental costs will also drop significantly
    6. If you do not publish the web version, you will not need to purchase a registered domain name. Mini Programs and Apps can use the server without a domain name;

uniCloud provides a free service space for each developer, so that you can also have your own server.

# Watch the video, just 25 minutes, get started quickly with uniCloud

# what uniCloud is and is not

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?

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, so that a developer who does not understand server operation and maintenance can only handle his own business, and no longer need to care about hot backup, load, capacity expansion, DDOS and other things.
  • Serverless, so that a student can also enjoy the world's top IT infrastructure.

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.

# uniCloud为何可降低云服务租用成本

**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.




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.

# uniCloud降低前端掌握后端的门槛

Front-end engineers want to master back-end development, there are 6 major barriers:

  • Learn non-js languages such as php and java
  • Learn database design
  • Learn SQL
  • Learn linux, nginx and other systems and third-party software
  • Learning server operation and maintenance: familiar with load balancing and large concurrent processing. Understand various complex cloud vendor product catalogs and quotes
  • Learn system security: avoid business security vulnerabilities (permission vulnerabilities, anti-SQL injection), operating system and third-party software patches, DDoS and other network attacks

With uniCloud, these thresholds are all lowered:

  1. uniCloud uses js to write back-end service code, no need to learn php or java separately, or even to master nodejs in advance. Just look at the api documentation of uniCloud.
  2. uniCloud is based on serverless. Developers do not need to understand linux, nginx, or be familiar with load balancing, large concurrency processing, or care about system patches and DDoS attacks. They only need to write cloud business code in js and upload it to uniCloud.
  3. uniCloud launched opendb, which contains a large number of open source database templates, and common data tables do not need to be designed by yourself. Through the opendb template, developers can quickly master database design.
  4. SQL also needs to be learned separately in the past, especially complex join table query and Tree query, which is not easy to master. uniCloud has launched JQL (Javascript Query Language), which can master database query by knowing js, and also provides a very simple operation package for linked table query and tree query.
  5. uniCloud provides uni-id, no need to develop an account system by yourself, login, registration, password modification, role permission system, and token management are all available.
  6. uniCloud provides a data permission control scheme in DB Schema that matches the role permission system of uni-id. This solution allows beginners to not make mistakes in permission control. In the clear permission configuration list, you can easily find out what you have missed, which is much simpler than analyzing whether there is a permission vulnerability in the big php code in the past. This solution also makes it easier for multiple people to collaborate, or for the secondary development of the project. Because of the existence of specifications, newcomers can easily understand the logic of the permission system of the old code.

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!

# uniCloud如何提升10倍开发效率?

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.

# a story

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:

  1. Provide many ready-made wheels, no need to write code yourself
  2. If there is no ready-made wheel, then use the schema2code code generation tool to generate the addition, deletion, modification, and checking pages of the database (the pages are generated directly, not the interface)
  3. If schema2code can’t be done and you need to write code, then using clientDB will save 80% of the server development work
  4. If you still need to write cloud code, then cloud objects make your development easier
  5. HBuilderX provides tool assistance in cloud collaboration
  6. The language of the terminal and the cloud is unified, which improves the efficiency of communication and recruitment
  7. The amount of code is reduced to one-tenth of the original, which increases the efficiency of code review and testing tenfold
  8. Serverless allows developers to focus on business without distracting operation and maintenance

Let's expand on each layer in turn.

# The first layer of efficiency improvement: provide many ready-made wheels

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

  • uni-id: No need to develop user systems. User registration, login (including social login, SMS verification code login, App one-click login), password modification or reset, token management, graphic verification code, RBAC permission role system...all related to users, regardless of front-end or cloud , the code is readily available. See details
  • uni-pay: No matter WeChat or Alipay, no matter App, WeChat applet, or Alipay applet, no matter front-end or server, everything is ready-made and ready to use. See details
  • uni-starter: A basic project template for rapid development of cloud-integrated applications to quickly build an application. It integrates many common functions, such as login registration, avatar, settings, interceptor, banner... see details
  • uni-admin: An admin background that is available on all sides. It comes with user management, authority management, role management, menu management, and business chart statistics. There are also many admin plugins, such as cms plugin, push, banner management plugin, App upgrade management plugin... See details
  • uni-search: Cloud unified search. Search pages, input associations, search history, analysis and extraction of hot search words... everything is available. See details
  • uni-file-picker: The front-end directly transmits the uniCloud storage component. See details
  • uni-captcha:云端一体图形验证码组件。详见
  • uni-upgrade-center: uni-upgrade-center. Support package upgrade, wgt hot update; support direct download of installation package or jump to the app store. See details
  • uni-push2: Cloud-integrated push, which greatly simplifies push development. See details
  • uni-im: open source IM. See details

2. Excellent plugins from the community

  • cms
  • city selection
  • banner management
  • feedback
  • log management
  • Sensitive word filtering

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.

  • uni_module: The best way to carry cloud-integrated components. Traditional npm cannot handle the requirements of cloud integration. The front-end and cloud code are packaged together into a uni_module for overall dissemination and release, which is of great help to the ecology of cloud-integrated components. See details
  • datacom: datacom is a component that binds back-end data sources on the front-end. See details

Excellent modular solutions make the ecology more and more prosperous.

# The second layer of efficiency: schema2code automatically generates code

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.

# The third layer of efficiency: clientDB, reducing server code by 80%

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:

    <unicloud-db v-slot:default="{data, loading, error, options}" collection="user" field="name" :getone="true" where="id=='1'">  
          {{ data.name}}  

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.

  • In traditional mysql or MongoDB, it is very troublesome to write a table query. There is no tree query mysql at all, and a professional database such as oracle is required. But in uniCloud, you only need to define the relationship between the fields of the two tables in the schema of the database, such as the reference relationship (foreignKey), or the parent-child relationship (parentKey), the front-end can directly query, and easily complete [join table query] ](https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=lookup) and tree query
  • There are very few operation methods in the SQL language, while JQL provides a large number of operation methods, such as date operation dayOfMonth(), string operation method substr(), number operation method add()... You can directly manipulate the value of database fields Compute and filter. For example, weighted summation of two fields in the database and then sorting, this traditional SQL statement can not be solved

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.

# Fourth layer efficiency improvement: cloud objects, changing front-end and back-end collaboration

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
	} catch (e) {
		// Compliant with uniCloud response body specification https://uniapp.dcloud.net.cn/uniCloud/cf-functions?id=resformat, this error will be thrown automatically

# Fifth layer efficiency: HBuilderX tools help

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.

# Level 6 Efficiency Improvement: The Value of Language Unity

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. .

# Seventh layer efficiency improvement: test efficiency improvement

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.

# Eighth layer efficiency improvement: serverless allows developers to focus on business without distracting operation and maintenance

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.