iupdate
This commit is contained in:
@@ -2,9 +2,9 @@ import { Meilisearch, type SearchResponse } from 'meilisearch'
|
||||
|
||||
const MAX_HITS_PER_PAGE = 100
|
||||
|
||||
export async function createSearch({
|
||||
export async function createSearch<T extends Record<string, any>>({
|
||||
query,
|
||||
filter = undefined,
|
||||
filter,
|
||||
index,
|
||||
page,
|
||||
hitsPerPage = 25,
|
||||
@@ -18,11 +18,11 @@ export async function createSearch({
|
||||
hitsPerPage?: number
|
||||
sort: string[]
|
||||
env: any
|
||||
}): Promise<SearchResponse> {
|
||||
}): Promise<SearchResponse<T>> {
|
||||
const host = env.MEILI_HOST
|
||||
const apiKey = env.MEILI_API_KEY
|
||||
const client = new Meilisearch({ host, apiKey })
|
||||
const index_ = client.index(index)
|
||||
const index_ = client.index<T>(index)
|
||||
|
||||
return index_.search(query, {
|
||||
sort,
|
||||
|
||||
Reference in New Issue
Block a user