using the repository that was created,
for instance you want to interact with the table users
and say you have the repository UserRepository.
- dependency inject the user repository into the current service
constructor(
@InjectRepository(Users)
private userRepository: Repository<UserRepository>
) {}
- now use the created userReposotory to run the command to invoke the stored procedure
this.userRepository.query("call dev_db.listUsers(?)",[the_input_paramenters_required]);
--the above query returns a promise with result of stored Procedure or error
So make sure you add await to function having the above line
Top comments (2)
BhargavMantha I am almos sure that
this.userRepository.query(
call dev_db.listUsers(${the_input_paramenters_required});
is prone to sql injection, you should use a param list instead.Thank you so much for pointing that out notaduck. My apologies for missing your comment. :)