Introduction
warning
WIP docs!
A Group categorizes and preserves the ordering of structured data in a Collection.
They allow us to cluster together data from a Collection as an array of primary Keys
.
A Group doesn't store the actual Items. It only keeps track of the primary Keys
and retrieves the fitting Items from the Collection later when needed.
Groups are dependent on a Collection Instance, and so we have to instantiate them with the help of one. By doing so, the Group gets automatically bound to the Collection it was created from and has access to its data. On the one hand we can define our Groups in the configuration object of the Collection.
Or on the other hand, we create them dynamically, which means after the Collection has been defined.
We can add as many Groups as we want, and the Collection won't lose its redundant behavior. This is due to the fact that each Item is stored in the Collection itself and not in the Group. You can imagine a Group like an interface to the Collection Data.
A Group is an extension of the State Class
and offers the same powerful features.
But be aware that the value
might not be the output you expect.
In a Group, the value
property doesn't hold the Item Values,
it contains the primary Keys
the Group represents.
To get the Item Value to each primary Keys
, we use the output
property.
#
🔨 UsageFor instance, we can use a Group to cluster a Post Collection into User Posts of the logged-in user.
In the above code snippet, we have two Collections, one for users and another for posts. We can collect posts specific to a user and group them automatically by the user's id.
#
⛳️ SandboxTest the Group yourself. It's only one click away. Just select your preferred Framework below.
- React
- Vue (coming soon)
- Angular (coming soon)