繁体   English   中英

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

[英]NestJS: Case-insensitive search in PostgreSQL

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

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

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

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

ILike选项应该适用于:

import {ILike} from "typeorm";

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

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


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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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