View isolate.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main(List<String> arguments, dynamic message) { | |
print('GITHUB: Arguments from your isolate: $arguments'); | |
print('GITHUB: Message from your isolate: $message'); | |
// V3 | |
} |
View tewtutin_27.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
START TRANSACTION | |
// ... | |
SELECT "Purse"."id" AS "Purse_id", "Purse"."balance" AS "Purse_balance", "Purse"."userId" AS "Purse_userId" | |
FROM "purse" "Purse" | |
WHERE "Purse"."id" IN ($1) | |
UPDATE "purse" | |
SET "balance" = $2 | |
WHERE "id" IN ($1) | |
SELECT "Purse"."id" AS "Purse_id", "Purse"."balance" AS "Purse_balance", "Purse"."userId" AS "Purse_userId" | |
FROM "purse" "Purse" |
View tewtutin_26.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
@Post('remittance-with-transaction-and-fee') | |
@ApiResponse({ | |
type: RemittanceResultDto, | |
}) | |
async makeRemittanceWithTransactionAndFee(@Body() remittanceDto: RemittanceDto) { | |
return this.connection.transaction(async manager => { | |
const transactionAppService = this.appService.withTransaction(manager); // <-- this is interesting new thing | |
const result = await transactionAppService.makeRemittance(remittanceDto.userIdFrom, remittanceDto.userIdTo, remittanceDto.sum, remittanceDto.withError); | |
result.fromBalance -= 1; // <-- transfer fee |
View tewtutin_25.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
START TRANSACTION | |
// ... | |
SELECT "Purse"."id" AS "Purse_id", "Purse"."balance" AS "Purse_balance", "Purse"."userId" AS "Purse_userId" | |
FROM "purse" "Purse" | |
WHERE "Purse"."id" IN ($1) | |
UPDATE "purse" | |
SET "balance" = $2 | |
WHERE "id" IN ($1) | |
ROLLBACK |
View tewtutin_24.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
START TRANSACTION | |
// ... | |
SELECT "Purse"."id" AS "Purse_id", "Purse"."balance" AS "Purse_balance", "Purse"."userId" AS "Purse_userId" | |
FROM "purse" "Purse" | |
WHERE "Purse"."id" IN ($1) | |
UPDATE "purse" | |
SET "balance" = $2 | |
WHERE "id" IN ($1) | |
SELECT "Purse"."id" AS "Purse_id", "Purse"."balance" AS "Purse_balance", "Purse"."userId" AS "Purse_userId" | |
FROM "purse" "Purse" |
View tewtutin_23.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class AppService extends TransactionFor<AppService> /* <-- step 1 */ { | |
constructor( | |
@InjectRepository(User) | |
private readonly userRepository: Repository<User>, | |
@InjectRepository(Purse) | |
private readonly purseRepository: Repository<Purse>, | |
private readonly appServiceV2: AppServiceV2, | |
moduleRef: ModuleRef, // <-- step 2 | |
) { |
View tewtutin_22.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Post('remittance-with-typeorm-transaction') | |
@ApiResponse({ | |
type: RemittanceResultDto, | |
}) | |
async makeRemittanceWithTypeOrmTransaction(@Body() remittanceDto: RemittanceDto) { | |
return await this.connection.transaction(transactionManager => { | |
return this.appService.makeRemittanceWithTypeOrmV1(transactionManager, remittanceDto.userIdFrom, remittanceDto.userIdTo, remittanceDto.sum, remittanceDto.withError); | |
}); | |
} |
View tewtutin_21.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
@Post('remittance-with-transaction') | |
@ApiResponse({ | |
type: RemittanceResultDto, | |
}) | |
async makeRemittanceWithTransaction(@Body() remittanceDto: RemittanceDto) { | |
return await this.connection.transaction(transactionManager => { | |
return this.appService.withTransaction(transactionManager)/* <-- this is interesting new thing*/.makeRemittance(remittanceDto.userIdFrom, remittanceDto.userIdTo, remittanceDto.sum, remittanceDto.withError); | |
}); | |
} |
View tewtutin_20.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller() | |
@ApiTags('app') | |
export class AppController { | |
constructor( | |
private readonly appService: AppService, | |
private readonly connection: Connection, // <-- use this | |
) { | |
} | |
// ... | |
} |
View tewtutin_19.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app.service.ts | |
@Transaction() | |
async makeRemittanceWithTypeOrmV2(fromId: number, toId: number, sum: number, withError: boolean, @TransactionManager() transactionEntityManager: EntityManager = null) { | |
// ... | |
await this.appServiceV2.savePurseInTransactionV2(fromPurse, transactionEntityManager); | |
// ... | |
} | |
// app.service-v2.ts | |
// .. |
NewerOlder