Home Reference Source
import Query from '~/models/Query.js'
public class | source

Query

Represents a searchable index/object.

Constructor Summary

Public Constructor
public

constructor(items: T[], pred: Function)

Creates a QueryList from a formatted map.

Method Summary

Public Methods
public

find(term: string): T[]

Returns candidate list for a given query term.

public

findPage(term: string, opts: Object): Object

Does a paged search

Public Constructors

public constructor(items: T[], pred: Function) source

Creates a QueryList from a formatted map. Use QueryList.from methods to construct this. You may not need to use such a complex formatting for simpler (e.g. letter) queries.

Params:

NameTypeAttributeDescription
items T[]

List of all items

pred Function

Returns search value for given object

Public Methods

public find(term: string): T[] source

Returns candidate list for a given query term. Uses fuzzy non-repetitive letter matching.

Params:

NameTypeAttributeDescription
term string

Term to search for

Return:

T[]

the candidate objects.

public findPage(term: string, opts: Object): Object source

Does a paged search

Params:

NameTypeAttributeDescription
term string
opts Object
  • optional
  • default: {}
opts.maxResults number
  • optional
  • default: 5

Max results

opts.page number
  • optional
  • default: 1

one-indexed

opts.searchEmpty boolean
  • optional
  • default: true

If to query empty

Return:

Object

Return Properties:

NameTypeAttributeDescription
results T[]
areMore boolean

If are more