使用 MySQL 线程池对压力测试的影响,下面使用两个文件,分别测试一下。代码:test1.js 使用了 MySQL 线程池:export async function test1(ctx) {
let pool = dbUtil.getPool();
let connection = await pool.getConnection();
let [rows] = await connection.query('select * from tb_user limit 10');
connection.release();
}
test2.js 未使用 MySQL 线程池:export
DATE_FORMAT(date, format)DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据。format 参数的格式有:%a Everyday name in Shortened form [Sun–Sat].
%b Month name in Shortened form [Jan – Dec].
%c Name of Month in numbers [0 – 12].
%D Daytime of the month in a numeric form, trailed by suffix [like 1st, 2nd, …].
%d Daytime of the
between...and(推荐)SELECT * FROM tb_code WHERE expired_at BETWEEN '2021-01-01 00:00:00' AND '2021-12-31 23:59:59';
大小于号SELECT * FROM tb_code WHERE expired_at '2021-01-01 00:00:00' AND expired_at '2021-12-31 23:59:59';
转换为比较,create_time若加了索引,不走索引SELECT * FROM k_student WHERE UNIX_TIMESTAMP(create_t
ReferenceError: __dirname is not defined in ES module scopeThis file is being treated as an ES module because it has a '.js' file extension and '/Users/ice/www/next/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.解决办法:import path
单元测试很重要,很多新兴的编程语言都是会内置对应的能力,但 Node.js 这块一直都是由社区来实现,前端同学耳熟能详的 Test Runner 有 Mocha、Jest。2022年04月19日正式发布的 Node.js 18.x ,终于,官方支持了 Test 能力。Fetch API 也被集成到这个版本中了。测试 API 接口在一定程度上代替 SuperTest 了。代码:import test from 'node:test';
import assert from 'assert/strict';
// 等价于 describe()
test('asynchronous passing