v2.7 (latest)
Query Entities ​
This guide explains how to retrieve Persisted Entity instances from the database.
Prerequisites ​
- You have a Ruleset with persistency enabled.
- You have saved at least one Persisted Entity instance. See Save and Update Entities.
Retrieve all instances ​
Use EntityClass.getAll() to retrieve all instances of a Persisted Entity.
- Open your Ruleset and create a Rule named
GetAllPersons. - Enter the following expression:
javascript
return Person.getAll().items- Click Try it out. The result is a list of all instances.
The result is paginated. By default, the first 20 instances are returned.
Use pagination ​
To control which page and how many items are returned, pass a meta object.
- Create a Rule with the following expression:
javascript
// Get the second page, 10 items per page
return Person.getAll({ pageIndex: 1, pageSize: 10 }).items- Click Try it out. The second page of results is returned.
To retrieve up to 9999 instances at once:
javascript
return Person.getAll({ pageSize: 9999 }).items