I have database called Beta and table called Keys. In that table I have a column licenseKey: string. I want to find the entire licenseKey from the portion of licenseKey.
Just like SQL below query:
SELECT *
FROM KEYS
WHERE licenseKey LIKE "%XYZ%"
I have following code in my controller file:
@Get('getByLicenseKey/:licenseKey')
async getByLicenseKey(@Param('licenseKey') licenseKey: string) {
console.log('dsaadfad');
return this.licenseKeyService.getKeyByLicenseKey(licenseKey);
}
Service file
async getKeyByLicenseKey(licenseKey: string): Promise<keys[]> {
return await this.keyRepo.find({ licenseKey: Like(`${licenseKey}`) });
}
This works for me.