crud
crud copied to clipboard
[Feature request] Allow to pass side-data param to typeorm
Motivation: #68
TypeORM has an ability to pass data as an additional free-shape param to repository operations, that is available on the query runner instance.
// user sends request during entity save
postRepository.save(post, { data: { request: request } });
// in logger you can access it this way:
logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner) {
const requestUrl = queryRunner && queryRunner.data["request"] ? "(" + queryRunner.data["request"].url + ") " : "";
console.log(requestUrl + "executing query: " + sql);
}
The example is from the end of: https://github.com/typeorm/typeorm/blob/master/docs/logging.md#using-custom-logger
If the passed data will be configurable somehow (maybe an async callback that gets request context of something more high-level/) it will be possible to implement #68 with
Nothing yet? need to get current user from request on Subscriber....
Same here, @kevinmelo . 🤧
I found this package (as a work around), and it seems to work for me: https://github.com/Papooch/nestjs-cls
However, this feature would be much appreciated and more reliable.
Same here, @kevinmelo . 🤧
At the end i using my own framework. And using connection pulls with TypeORM to save the current user from the request at the transaction
How did you do that?