Filter helper functions for creating consistent sorting criteria in database subclasses. These functions should be tested with “&&“ operatos between them for consistency between implementations (all supplied criteria must match, but if nothing is supplied, no match is made).
- Description:
Filter helper functions for creating consistent sorting criteria in database subclasses. These functions should be tested with “&&“ operatos between them for consistency between implementations (all supplied criteria must match, but if nothing is supplied, no match is made).
- Source:
Methods
(inner) idFilter(m, id) → {boolean}
- Description:
Filters models by ID.
- Source:
Example
models.filter(m => idFilter(m, "item123"));
Parameters:
| Name | Type | Description |
|---|---|---|
m |
Object | The model to test |
id |
* | The ID to match against (undefined means no filtering) |
Returns:
True if the model matches or no ID filter is specified
- Type
- boolean
(inner) namesFilter(m, name) → {boolean}
- Description:
Filters models by checking if a name exists in the model's names array.
- Source:
Example
models.filter(m => namesFilter(m, "John"));
Parameters:
| Name | Type | Description |
|---|---|---|
m |
Object | The model to test |
name |
string | The name to search for (undefined means no filtering) |
Returns:
True if the model contains the name or no name filter is specified
- Type
- boolean
(inner) tagFilter(m, tags) → {boolean}
- Description:
Filters models by tags using tag matching logic.
- Source:
Example
models.filter(m => tagFilter(m, "weapon firearm"));
Parameters:
| Name | Type | Description |
|---|---|---|
m |
Object | The model to test |
tags |
string | The tag filter string (undefined means no filtering) |
Returns:
True if the model matches or no tag filter is specified
- Type
- boolean
(inner) typeFilter(m, type) → {boolean}
- Description:
Filters models by type (case-insensitive).
- Source:
Example
models.filter(m => typeFilter(m, "weapon"));
Parameters:
| Name | Type | Description |
|---|---|---|
m |
Object | The model to test |
type |
string | The type to match against (undefined means no filtering) |
Returns:
True if the model matches or no type filter is specified
- Type
- boolean