728x90
๐จ ๋ฐ์ํ ๋ฌธ์ ์ ์ํฉ
mode: "insensitive" ์ต์ ์ด Prisma์ ์ผ๋ถ ๋ฐ์ดํฐ๋ฒ ์ด์ค(MySQL, PostgreSQL ๋ฑ)์์ ์ง์๋์ง ์๋ ๋ฌธ์
//ํ ๊ฒ์ ๊ธฐ๋ฅ (์ ๋ชฉ, ๋ด์ฉ, ํด์ํ๊ทธ ํฌํจ)
254 public async searchTips(query: string | null, hashtags: string[], skip: number, take: number, sort: string) {
→ 255 return await prisma.tip.findMany({
where: {
AND: [
{
OR: [
{
title: {
contains: "1",
mode: "insensitive"
}
},
{
content: {
contains: "1",
mode: "insensitive"
}
}
]
},
{
hashtags: {
some: {
hashtag: {
name: {
in: [
"#์ฒญ์"
]
}
}
}
}
}
]
},
skip: 0,
take: 10,
orderBy: {
created_at: "desc"
},
include: {
media: true,
hashtags: {
include: {
hashtag: true
}
},
user: {
select: {
user_id: true,
nickname: true,
profile_image_url: true
}
},
likes: true,
saves: true
}
})
Unknown argument mode. Did you mean lte? Available options are marked with ?.
at xn (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:29:1363)
at Bn.handleRequestError (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:121:7005)
at Bn.handleAndLogRequestError (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:121:6686)
at Bn.request (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:121:6393)
at async l (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:130:9645)
at TipRepository.searchTips (D:\\umc-h-master\\src\\repositories\\tip.repository.ts:255:12)
at TipService.searchTips (D:\\umc-h-master\\src\\services\\tip.service.ts:234:18)
at TipController.searchTips (D:\\umc-h-master\\src\\controllers\\tip.controller.ts:823:22) {
clientVersion: '6.3.1'
}
๐ค ๋ฌธ์ ์ ์์ธ ํ์ ํ๊ธฐ
- mode: "insensitive" ์ต์ ์ PostgreSQL์์๋ง ์ฌ์ฉ ๊ฐ๋ฅํ๋ฉฐ, MySQL์์๋ ์ง์๋์ง ์์.
๐กํด๊ฒฐ์ฑ : MySQL์์ ๊ธฐ๋ณธ์ ์ผ๋ก utf8_general_ci ๋๋ utf8mb4_general_ci ์ปฌ๋ ์ด์ ์ ์ฌ์ฉํ๋ฉด, ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ์ง ์๋ ๊ฒ์์ด ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์ Prisma์ ๊ธฐ๋ณธ ๊ฒ์ ๊ธฐ๋ฅ(contains)์ ์ฌ์ฉํ๋ฉด ๋๋ค.
๐๐ปโ๏ธ ์๋ํด๋ณธ ๋ฐฉ๋ฒ
mode: "insensitive" ์ต์ ์ ์ ๊ฑฐํ๊ณ , ๋์๋ฌธ์ ๊ตฌ๋ถ ์์ด ๊ฒ์์ด ๊ฐ๋ฅํ๋๋ก Prisma ๊ธฐ๋ณธ ์ค์ ์ ์์กดํ๋๋ก ์ฝ๋๋ฅผ ์์ ํ๋ค
// โ
ํ ๊ฒ์ ๊ธฐ๋ฅ (์ ๋ชฉ, ๋ด์ฉ, ํด์ํ๊ทธ ํฌํจ)
public async searchTips(query: string | null, hashtags: string[], skip: number, take: number, sort: string) {
return await prisma.tip.findMany({
where: {
AND: [
query
? {
OR: [
{ title: { contains: query } }, // โ
`mode: "insensitive"` ์ ๊ฑฐ
{ content: { contains: query } }
],
}
: {}, // โ
๊ฒ์์ด๊ฐ ์์ผ๋ฉด ๋ฌด์
hashtags.length > 0
? {
hashtags: {
some: {
hashtag: {
name: { in: hashtags },
},
},
},
}
: {}, // โ
ํด์ํ๊ทธ๊ฐ ์์ผ๋ฉด ๋ฌด์
],
},
skip,
take,
orderBy: this.getSortOption(sort), // โ
์ ๋ ฌ ์ต์
์ ์ฉ
include: {
media: true,
hashtags: { include: { hashtag: true } },
user: { select: { user_id: true, nickname: true, profile_image_url: true } },
likes: true,
saves: true,
},
});
}
โ ๊ฒฐ๋ก
mode: "insensitive" ์ ๊ฑฐ → MySQL์์๋ ์ง์๋์ง ์์ผ๋ฏ๋ก ์ญ์
728x90
'{Troubleshooting}' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํธ๋ฌ๋ธ์ํ ] TMAP 204 NO_CONTENT ์ค๋ฅ (0) | 2025.09.29 |
---|---|
[ํธ๋ฌ๋ธ์ํ ] Git merge conflict ์ฒ๋ฆฌ ๋ฐฉ๋ฒ (3) | 2025.07.28 |
[ํธ๋ฌ๋ธ ์ํ ] AWS SDK์ Multer-S3 ํธํ์ฑ ๋ฌธ์ ๋ฐ์ (0) | 2025.03.03 |
[ํธ๋ฌ๋ธ ์ํ ] AWS s3 ์ด๋ฏธ์ง ๊นจ์ง๋ ํ์ (0) | 2025.03.03 |