Skip to content

Commit 73b5f4f

Browse files
committed
移除trx.id
1 parent 8cc6e50 commit 73b5f4f

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/libs/MysqlBin.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { echo } from 'coa-echo'
22
import { CoaError } from 'coa-error'
3-
import { secure } from 'coa-secure'
43
import { MysqlCache } from '../services/MysqlCache'
54
import { CoaMysql } from '../typings'
65
import { Knex } from './Knex'
@@ -33,11 +32,9 @@ export class MysqlBin {
3332
}
3433

3534
async safeTransaction<T>(handler: (trx: CoaMysql.Transaction) => Promise<T>): Promise<T> {
36-
3735
let cacheTasks = [] as Array<{ model: MysqlCache<any>, ids: string[], dataList: any[] }>
3836

3937
const result = await this.io.transaction(async (trx: any) => {
40-
trx.id ||= secure.id25(`${Date.now()}-${Math.floor(Math.random() * 1e6).toString().padStart(6, '0')}`)
4138
// 收集事务更新缓存数据
4239
trx.trxUpdateCacheTaskList = async (model: MysqlCache<any>, ids: string[], dataList: any[]) => {
4340
cacheTasks.push({ model, ids, dataList })

src/test/demo.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ const User = new (class extends MysqlCache<UserScheme> {
6969
title: '用户表', // 表的备注名称
7070
scheme: userScheme, // 表的默认结构
7171
pick: ['userId', 'name'], // 查询列表时显示的字段信息
72-
caches: { index: ['name'], count: ['userId', 'name'] }
72+
caches: { index: ['name'], count: ['userId', 'name'] },
73+
7374
},
7475
mysqlBin,
7576
redisCache,

0 commit comments

Comments
 (0)