Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: support Fuse.js 6.x.x #15

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

refactor: support Fuse.js 6.x.x #15

wants to merge 2 commits into from

Conversation

cuebit
Copy link
Member

@cuebit cuebit commented Sep 3, 2020

Type of PR:

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Documentation
  • Other, please describe:
    • Depedency upgrade (Fuse.js)

Breaking changes:

  • No
  • Yes (allegedly)

Details

This PR brings the plugin to a much needed alignment with the latest version of Fuse.js (v6 at time of writing). As of v6, the lib has improved significantly concerning performance and additions for extensive search capability.

Breaking Changes

Fuse v6 does introduces breaking changes, most notably the formatting of search results which now incorporate a search score, character matches, etc.

// Example of the library output:
type SearchResult = {
  item: Model
  refIndex: number
  score?: number
  matches?: Array<{
    indices: Array<[number, number]>
    key?: string
    refIndex?: number
    value?: string
  }>
}

We can alleviate these by continuing to return a model collection. That being said, the raw search results are still accessible, should they be needed for the additional metadata, on the query instance the search modifier was applied:

const query = Model.query().search(...)
const results = query.get()

console.log(query.searchResults)

To mitigate any migration complications, much of the refactoring takes legacy input into consideration. For example, array inputs are still a valid form of expression:

Model.query().search('vuex orm')
// is the equivalent of
Model.query().search(['vuex', 'orm'])

Various options have been removed including, but not limited to, tokenization options, maxPatternLength, matchAllTokens and id. These aren't considering breaking changes per-se, but can have an impact on expectations.

See the library CHANGELOG for more information.

TODO

  • Update documentation

@cuebit cuebit added enhancement New feature or request dependencies Pull requests that update a dependency file labels Sep 3, 2020
@cuebit cuebit self-assigned this Sep 3, 2020
@codecov
Copy link

codecov bot commented Sep 3, 2020

Codecov Report

Merging #15 into dev will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##               dev       #15   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines           35        41    +6     
  Branches         5         5           
=========================================
+ Hits            35        41    +6     
Impacted Files Coverage Δ
src/VuexORMSearch.ts 100.00% <ø> (ø)
src/config/DefaultOptions.ts 100.00% <100.00%> (ø)
src/index.ts 100.00% <100.00%> (ø)
src/mixins/Query.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76a1d41...fc7499a. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant