Skip to content

Commit 57d0c8e

Browse files
author
Conan Crawford
committed
0.1.7 Release - Add feature to use Array of terms & update docs
1 parent a9ff81b commit 57d0c8e

File tree

5 files changed

+92
-51
lines changed

5 files changed

+92
-51
lines changed

README.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,38 @@ const data = this.$store.getters['entities/users/query']()
1414
```
1515

1616
### API
17+
The search plugin method accepts two parameters
18+
19+
- **term** : any string or an array of strings
20+
- **options** : see the _Fuse.js Default Options_ below
21+
22+
**Note:** If passing an array of search terms, the results assume every element in the array must be matched.
1723

1824
```typescript
19-
search(term: any, options: Object<any>): Array<Records>
25+
search(term: string | Array<string>, options: Object<any>): Array<Records>
2026
```
2127

2228
## Requirements:
2329

24-
The search plugin requires vuex-orm package version 0.15+
30+
The search plugin requires **@vuex-orm/core** package version 0.16.1
2531

2632
To upgrade the **vuex-orm package** simply run
2733
```bash
28-
npm install vuex-orm@latest --save
34+
npm install @vuex-orm/core
2935
```
3036

3137
## Installation
3238
```bash
3339
npm install @vuex-orm/plugin-search --save
3440
```
3541

36-
### Plugin Import Directions
42+
## Plugin Import Directions
3743

3844
Import the search plugin in the Vuex Store entry file.
3945

4046
```javascript
4147
// ex: store/index.js
42-
import VuexORM from 'vuex-orm'
48+
import VuexORM from '@vuex-orm/core'
4349
import VuexORMSearch from '@vuex-orm/plugin-search'
4450
````
4551

@@ -51,7 +57,7 @@ VuexORM.use(VuexORMSearch, {
5157
})
5258
```
5359

54-
### Fuse.js Default Options
60+
## Fuse.js Default Options
5561

5662
The plugin provides opinionated default fuse.js options for token based matching for optimum performance. These options are easily changed at two stages of the plugin lifecycle:
5763

@@ -79,7 +85,9 @@ see: [Fuse.js](http://fusejs.io/) for demo
7985

8086
## Option Use Examples
8187

82-
**During Plugin Install**
88+
Some examples on how to use the search plugin with case specific options
89+
90+
### During Plugin Install
8391

8492
For example, if we want to match based on case sensitive and no fuzzy search logic (perfect match)
8593
```javascript
@@ -89,7 +97,7 @@ VuexORM.use(VuexORMSearch, {
8997
})
9098
```
9199

92-
**During Query Chain**
100+
### During Query Chain
93101

94102
The global install options will now default to case sensitive and no fuzzy logic, but for example we have a run-time case we need to ignore case and implement a slightly more strict fuzzy search threshold.
95103

@@ -109,3 +117,17 @@ const data = this.$store.getters['entities/users/query']()
109117
.get()
110118
```
111119

120+
### Finding Results Matching Multiple Terms
121+
122+
Let's find all matches where both **pat** and **male** exist in our records, and sort by the date added.
123+
124+
```javascript
125+
const terms = ['pat', 'male']
126+
const options = {
127+
keys: ['firstName', 'gender']
128+
}
129+
const data = this.$store.getters['entities/users/query']()
130+
.search(terms, options)
131+
.orderBy('createdAt', 'desc')
132+
.get()
133+
```

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)