简体   繁体   中英

NestJS: Case-insensitive search in PostgreSQL

Is there any way to do a case-insensitive search with NestJS in PostgreSQL?

I've succeeded in doing a case-sensitive search:

let result = await myRepository.findOne({firstName: fName, lastName: lName});

I'm trying to change it to a case-insensitive search.

The ILike option should work for that:

import {ILike} from "typeorm";

const loadedPosts = await connection.getRepository(Post).find({
    title: ILike("%out #%")
});

Example from https://typeorm.io/#/find-options/advanced-options


For ILIKE in Postgres see https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE

The key word ILIKE can be used instead of LIKE to make the match case-insensitive according to the active locale. This is not in the SQL standard but is a PostgreSQL extension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM