Collections
WireBootstrap collections allow an array of objects to be managed using one of the attributes as a key.

Create a Collection

To create a collection, create a new instance of the wire.Collection class passing in the key field that makes each row unique along with the array of data.
1
let users = [
2
{ UserName: "jkratz", FullName: "Jamie Kratz", Active: true },
3
{ UserName: "pdougherty", FullName: "Pat Dougherty" Active: true },
4
{ UserName: "mchermela", FullName: "Mike Chermela", Active: false }
5
];
6
7
let col = new wire.Collection("UserName", users);
Copied!

Add an Object

To add an object, use the set method on the collection. This method will add the object to the collection if it does not already exist. If the object exists, it will be overwritten with the object that is passed into the method.
1
...
2
3
const amy = { UserName: "apeters", FullName: "Amy Peters", Active: true };
4
5
const mike = col.set(amy);
Copied!

Retrieve an Object

To pull an object out of the collection, use the get method with the key value.
1
...
2
3
const mike = col.get("mchermela");
Copied!

Remove an Object

Use the remove method with the key to remove an object from the collection.
1
...
2
3
col.remove("jkratz");
Copied!

Retrieve the Array

To pull the array out of the collection, use the array method.
1
...
2
3
const users = col.array();
Copied!
For more on WireBootstrap collections, visit wire.Collection.