On This Page
Collection Helpers
Collection Helpers are methods available on ReactiveVar instances that contain arrays of objects. These helpers provide convenient ways to manipulate and update specific objects within the collection based on their unique id.
Element IDs
Unique ids for each row are the first set value in the following list
_id
id
hash
key
If none are set then the record will be ignored
setProperty
Sets a property on an object in the collection that matches the given id.
Syntax
Parameters
Name | Type | Description |
---|---|---|
id | any | The id of the object to modify |
property | string | The name of the property to set |
value | any | The value to set for the property |
Usage
replaceItem
Replaces an entire object in the collection that matches the given id.
Syntax
Parameters
Name | Type | Description |
---|---|---|
id | any | The id of the object to replace |
newItem | Object | The new object to replace the old one |
Usage
removeItem
Removes an object from the collection that matches the given id.
Syntax
Parameters
Name | Type | Description |
---|---|---|
id | any | The id of the object to remove |
Usage
getIndex
Returns the index of an object in the collection that matches the given id.
Syntax
Parameters
Name | Type | Description |
---|---|---|
id | any | The id of the object to find |
Returns
number - The index of the object, or -1 if not found.
Usage
getID
Returns the id of an object at a specific index in the collection.
Syntax
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the object |
Returns
any - The id of the object at the specified index, or undefined if the index is out of bounds.
Usage
hasID
Checks if an object at a specific index in the collection has an id.
Syntax
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the object to check |
Returns
boolean - True if the object at the specified index has an id, false otherwise.