Reputation: 362
I'm trying to query on a columns with SQL endswith in a Typescript app
cont tracking_code = '65432'
repo.findValidOne({ where: { tracking_code }});
I want to change it so the tracking_code
value ends with the tracking value that I have available on the code
The SQL equivalent would be
SELECT *
FROM repo
WHERE tracking_code LIKE '%65432'
LIMIT 1;
I have tried using a raw query, but it's not what I want.
Upvotes: 2
Views: 6122
Reputation: 13539
You need to use Like
find operator.
import {Like} from 'typeorm';
cont tracking_code = '65432';
repo.findValidOne({ where: { tracking_code: Like(`%${tracking_code}`) }});
Upvotes: 5