Custom Search Engine

If the available Search Engines does not fit your needs you can integrate your own custom search engine.

Writing the Engine

Your Search Engine should extend the MagnifyEngine class and implement the following methods:

import { SearchableModel, SearchableRow } from '@foadonis/magnify/types'
import {  } from '@foadonis/magnify'
 
export class  extends  {
  async (...: SearchableRow[]) {}
 
  async (...: SearchableRow[]) {}
 
  async (: ) {}
 
  async (: , : any) {}
 
  async (: , : number, : number) {}
 
  async (: SearchableModel) {}
}

You can head to the natively supported Search Engines source code for more information about the implementation.

Registering the Engine

You can now add your CustomSearchEngine to the config/magnify.ts file:

config/magnify.ts
const  = defineConfig({
  : 'custom',
  : {
    : new CustomSearchEngine(),
  },
})
 
export default 

On this page