@AfterInsert() / @BeforeInsert() can only be invoked once per server re-start
See original GitHub issueIssue type:
[ ] question [ x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ x] mysql
/ mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
I’m testing this against my local mysql@5.7 db as well as serverless aurora via typeorm-aurora-data-api-driver
(for what thats worth).
I’m also running this code via serverless-offline
The before/after-insert hooks appear to only run if they are the very first invocation made by the DB runner - all subsequent actions work correctly, selecting / creating / updating / deleting - but they skip these hooks.
Also I’ve tested this via both ActiveRecord and Data Mapper approaches and the result appears to be the same.
example code
@Entity()
export class MyClass extends BaseEntity {
@PrimaryGeneratedColumn("uuid")
@Generated("uuid")
id: string;
@Column()
name: string;
@AfterInsert()
doSomething() {
console.log("this only runs on the first invocation", this);
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
hope it will help you as well, when running serverless offline with
solves the problem locally, not sure about production yet.
Please note, that in new version of serverless-offline
--skipCacheInvalidation
does not exist use--allowCache
instead