@@ -174,24 +174,26 @@ export class TableRepository implements ITableRepository {
174
174
}
175
175
176
176
async find ( spec : Option < TableComositeSpecification > , ignoreSpace ?: boolean ) : Promise < TableDo [ ] > {
177
- const query = this . qb
177
+ const tx = this . txContext . getCurrentTransaction ( )
178
+ const query = tx
178
179
. selectFrom ( "undb_table" )
179
180
. selectAll ( "undb_table" )
180
181
. $if ( spec . isSome ( ) , ( qb ) => new TableReferenceVisitor ( qb ) . call ( spec . unwrap ( ) ) )
181
182
. where ( ( eb ) =>
182
- new TableDbQuerySpecHandler ( this . qb , eb , this . context . mustGetCurrentSpaceId ( ) , ignoreSpace ) . handle ( spec ) ,
183
+ new TableDbQuerySpecHandler ( tx , eb , this . context . mustGetCurrentSpaceId ( ) , ignoreSpace ) . handle ( spec ) ,
183
184
)
184
185
const tbs = await query . execute ( )
185
186
186
187
return tbs . map ( ( t ) => this . mapper . toDo ( t ) )
187
188
}
188
189
189
190
async findOne ( spec : Option < TableComositeSpecification > ) : Promise < Option < TableDo > > {
190
- const tb = await this . qb
191
+ const tx = this . txContext . getCurrentTransaction ( )
192
+ const tb = await tx
191
193
. selectFrom ( "undb_table" )
192
194
. selectAll ( "undb_table" )
193
195
. $if ( spec . isSome ( ) , ( qb ) => new TableReferenceVisitor ( qb ) . call ( spec . unwrap ( ) ) )
194
- . where ( ( eb ) => new TableDbQuerySpecHandler ( this . qb , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
196
+ . where ( ( eb ) => new TableDbQuerySpecHandler ( tx , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
195
197
. executeTakeFirst ( )
196
198
197
199
if ( ! tb ) {
@@ -203,24 +205,25 @@ export class TableRepository implements ITableRepository {
203
205
204
206
async findOneById ( id : TableId ) : Promise < Option < TableDo > > {
205
207
const spec = Some ( new TableIdSpecification ( id ) )
206
- const tb = await this . qb
208
+ const tx = this . txContext . getCurrentTransaction ( )
209
+ const tb = await tx
207
210
. selectFrom ( "undb_table" )
208
211
. selectAll ( "undb_table" )
209
212
. $call ( ( qb ) => new TableReferenceVisitor ( qb ) . call ( spec . unwrap ( ) ) )
210
- . where ( ( eb ) => new TableDbQuerySpecHandler ( this . qb , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
213
+ . where ( ( eb ) => new TableDbQuerySpecHandler ( tx , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
211
214
. executeTakeFirst ( )
212
215
213
216
return tb ? Some ( this . mapper . toDo ( tb ) ) : None
214
217
}
215
218
216
219
async findManyByIds ( ids : TableId [ ] ) : Promise < TableDo [ ] > {
217
220
const spec = Some ( new TableIdsSpecification ( ids ) )
218
- const tbs = await this . txContext
219
- . getCurrentTransaction ( )
221
+ const tx = this . txContext . getCurrentTransaction ( )
222
+ const tbs = await tx
220
223
. selectFrom ( "undb_table" )
221
224
. selectAll ( "undb_table" )
222
225
. $call ( ( qb ) => new TableReferenceVisitor ( qb ) . call ( spec . unwrap ( ) ) )
223
- . where ( ( eb ) => new TableDbQuerySpecHandler ( this . qb , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
226
+ . where ( ( eb ) => new TableDbQuerySpecHandler ( tx , eb , this . context . mustGetCurrentSpaceId ( ) ) . handle ( spec ) )
224
227
. execute ( )
225
228
226
229
return tbs . map ( ( t ) => this . mapper . toDo ( t ) )
0 commit comments