Specifically, is there way to access the last_inserted_id in a TypeORM transaction? i.e.:
try {
// transaction
await getManager().transaction(async (trManager): Promise<any> => {
const company = new Company();
const savedCompany = await trManager.save(company);
const companyId = savedCompany.lastInsertedId;
// ..............more saves..............//
// await trManager.save(otherEntityUsingCompanyId);
});
} catch (err) {
console.error("err: ", err);
}
I've looked through the docs thoroughly (admittedly, perhaps not thoroughly enough if i've missed something) and haven't seen anything. The closest documentation I've found that looks similar is:
const userId = manager.getId(user); // userId === 1
This seems like a common enough use case that I'm assuming I missed something, which is why I've hesitated to file an issue. Any help would be appreciated. Thanks!