How can to search column with case insensitive with findAndCount
See original GitHub issueIssue type:
[ x ] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[ x ] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ‘x’ ] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
const [results, total] = await this.userRepository.findAndCount({
where: {
name: Like(`%${options.keywords}%`),
status: Equal(options.status)
},
order: { id: "DESC" },
take: options.limit,
skip: options.skip,
})
How can to search the name column with case insensitive in findAndCount api. I saw another solution is use query builder like below , so how to achieve this in findAndCount. Thanks you so much.
const posts = await repository.createQueryBuilder()
.where("LOWER(title) = LOWER(:title)", { title })
.getMany();
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9 (2 by maintainers)
Top Results From Across the Web
TypeOrm Postgres case sensitive on where clause value
I 'm having case-sensitivity issues with my select queries. This is my NestJs controller Search method: search(payload: SearchPayload): ...
Read more >Case-Insensitive Search in SQL - Use The Index, Luke
Ignoring the case in a where clause is very simple. You can, for example, convert both sides of the comparison to all caps...
Read more >Model Querying - Basics - Sequelize
Simple SELECT queries. You can read the whole table from the database with the findAll method: // Find all users
Read more >How to do case-insensitive and accent-insensitive search in ...
Accent-insensitive search; Sort rows regardless of case or accents; Define search and sorting rules for a column; Ignore case or diacritics ...
Read more >How to Check Case-Sensitivity in SQL Server - Webucator
SQL Server is, by default, case insensitive; however, it is possible to create a case-sensitive SQL Server database and even to make specific...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this is what you need exactly
Just wondering, would it not be possible for TypeORM to support a pattern like this?
Where string properties that are not included in the model’s properties don’t get magically resolved to the associated model property column and are instead used literally in the query e.g.
This requires the developer to ensure it matches up to actual database columns without any type safety against the model’s defined properties, but it’s still a nicer API than constructing queries manually with QueryBuilder where you don’t get any type safety on column names anyway.