NestJS:PostgreSQL 中不区分大小写的搜索

lot*_*tan 4 postgresql node.js typeorm

有没有办法在 PostgreSQL 中使用 NestJS 进行不区分大小写的搜索?

我已经成功地进行了区分大小写的搜索:

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

我正在尝试将其更改为不区分大小写的搜索。

Jen*_*nsV 7

ILike选项应该适用于此:

import {ILike} from "typeorm";

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

来自https://typeorm.io/#/find-options/advanced-options的示例


对于ILIKEPostgres 中的内容,请参阅https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE

可以使用关键字 ILIKE 代替 LIKE,以使匹配根据活动区域设置不区分大小写。这不在 SQL 标准中,而是 PostgreSQL 扩展。