StoreSearch
Properties
2
Properties
2Functions
6
Functions
6Finds the first record for which the specified function returns true
| Parameter | Type | Description |
|---|---|---|
fn | function | Comparison function, called with record as parameter |
searchAllRecords | Boolean | True to ignore any applied filters when searching |
Record or undefined if none found
store.find(record => record.color === 'blue');
Find occurrences of the specified value in the specified field on all locally available records in the store
| Parameter | Type | Description |
|---|---|---|
field | String | The record field to search in |
value | * | Value to search for |
distinct | Boolean | True to only return distinct matches, no duplicates |
searchAllRecords | Boolean | True to ignore any applied filters when searching |
Array of hits, in the format { index: x, data: record }
Finds the first record for which the specified field has the specified value
| Parameter | Type | Description |
|---|---|---|
fieldName | String | Field name |
value | * | Value to find |
searchAllRecords | Boolean | True to ignore any applied filters when searching |
Record or undefined if none found
Searches the Store records using the passed function.
| Parameter | Type | Description |
|---|---|---|
fn | function | A function that is called for each record. Return true to indicate a match |
searchAllRecords | Boolean | True to ignore any applied filters when searching |
An array of the matching Records
Find all hits matching the specified input.
const store = new Store({
fields : ['name', 'kind'],
data : [
{ id : 1, name : 'Batman', kind : 'hero' },
{ id : 2, name : 'Batkid', kind : 'hero' },
{ id : 3, name : 'Joker', kind : 'villain' },
{ id : 4, name : 'Penguin', kind : 'villain' }
]
});
store.search('villain'); // [{ index : 2, data : joker-record }, { index : 3, data : penguin-record }]
| Parameter | Type | Description |
|---|---|---|
text | String | Value to search for |
fields | String[] | Fields to search value in, searches in all defined fields if not specified |
formatters | function()[] | An array of field formatting functions to format the found value |
searchAllRecords | Boolean | True to ignore any applied filters when searching |
Array of hits, in the format { index: x, data: record }
Returns true if the supplied function returns true for any record in the store
| Parameter | Type | Description |
|---|---|---|
fn | function | A function that should return true to indicate a match |
searchAllRecords | Boolean | True to ignore any applied filters when searching |
store.some(record => record.age > 95); // true if any record has age > 95
Typedefs
1
Typedefs
1Format returned by Store#findByField().
| Parameter | Type | Description |
|---|---|---|
index | Number | Index of the record in the store |
data | Model | The record |