NestJS: 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


ILIKE在Postgres见https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE

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

最新更新