[typeOrm]Rawクエリの使用例
1 Ilikeよりも、likeを小文字で置き換えると が検索されます.
ソース
https://github.com/typeorm/typeorm/issues/1231
https://github.com/typeorm/typeorm/blob/master/docs/find-options.md
https://github.com/typeorm/typeorm/issues/4418
https://github.com/typeorm/typeorm/issues/3329
https://github.com/typeorm/typeorm/issues/2475
// already there
querybuilder
.[...]
.where('LOWER(users.email) = :email', { email: email.toLowerCase() });
// unsafe via repository, since params are unescaped:
repo.findOne({
where: {
email: Raw(alias => `LOWER(${alias}) = '${email.toLowerCase()}'`).
},
});
// would be nice to have:
repo.findOne({
where: {
email: Raw(alias => 'LOWER(${alias}) = :email', { email: email.toLowerCase() }),
},
});
2const [result, total] = await this.findAndCount(
{
where: { title: Raw(alias => `LOWER(${alias}) Like '%${value}%'`) },
take: take,
skip: skip
}
);
return {
data: result,
count: total
}
ソース
https://github.com/typeorm/typeorm/issues/1231
https://github.com/typeorm/typeorm/blob/master/docs/find-options.md
https://github.com/typeorm/typeorm/issues/4418
https://github.com/typeorm/typeorm/issues/3329
https://github.com/typeorm/typeorm/issues/2475
Reference
この問題について([typeOrm]Rawクエリの使用例), 我々は、より多くの情報をここで見つけました https://velog.io/@jeong3320/typeOrmRaw-쿼리-사용예시テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol