First, the previous introduction
Front-end use node for Web development, involving database operations, we commonly used methods are
- Direct use of
mysql
package - use
orm
kit- sequelize
- typeorm
For front-end partners, if you do not know native SQL statements, you can only spend time to learn the use of some ORM libraries, but I do not recommend using ORM.
Orm started out well, trying to completely automate object and database mapping so that users don’t care about the database. Excessive encapsulation is bound to cause another problem — the increase in hidden complexity. In my opinion, hiding complexity is worse than query statements. There are many beautiful ORM frameworks, such as Hibernate, which was once very popular in the Java world. It is very powerful and very popular in the community, but few people actually use it in production. Instead, some simple and lightweight frameworks are used on a large scale. And Internet applications, high performance requirements, so the CONTROL of SQL also need to be more direct and fine. Many Internet companies also don’t recommend using foreign keys, because DB is often the bottleneck and relationship maintenance can be done on the application server, so the ORM framework mapping definition is not necessarily useful, plus if you use ORM all the time, you will gradually forget about native SQL statements
Second, about theali-rds-async
The introduction of
When using the egg framework, I have used the egg-mysql connection to the database, I think it is good, so check the underlying is using an Ali-RDS of Ali, But it is written in genterator mode, ali-rDS-async, which simply uses typescript and co modules to change generator to promise
Three, the main implementation method
-
query
Use nativesql
statements -
insert
Insert statement -
update
Update a single statement -
updateRows
Update multiple statements -
get
Get a piece of data -
select
Query data -
delete
Delete the data -
count
count -
beginTransaction
The transaction