kopia lustrzana https://github.com/Stopka/fedisearch
Simplified feed query
rodzic
84a0460596
commit
1c0fd9f21e
|
@ -11,14 +11,6 @@ const handleFeedSearch = async (req: NextApiRequest, res: NextApiResponse<FeedRe
|
||||||
const phrases = feedRequest.search.trim().split(/[\s+]+/)
|
const phrases = feedRequest.search.trim().split(/[\s+]+/)
|
||||||
const feeds = await prisma.feed.findMany({
|
const feeds = await prisma.feed.findMany({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
fulltext: {
|
|
||||||
search: phrases.join(' & '),
|
|
||||||
mode: 'insensitive'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
AND: phrases.map(phrase => {
|
AND: phrases.map(phrase => {
|
||||||
return {
|
return {
|
||||||
fulltext: {
|
fulltext: {
|
||||||
|
@ -27,8 +19,6 @@ const handleFeedSearch = async (req: NextApiRequest, res: NextApiResponse<FeedRe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
take: pageLimit + 1,
|
take: pageLimit + 1,
|
||||||
skip: (feedRequest.page ?? 0) * pageLimit,
|
skip: (feedRequest.page ?? 0) * pageLimit,
|
||||||
|
|
Ładowanie…
Reference in New Issue