Skip to content
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.

  1. Open your Ruleset and create a Rule named GetAllPersons.
  2. Enter the following expression:
javascript
return Person.getAll().items
  1. 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.

  1. Create a Rule with the following expression:
javascript
// Get the second page, 10 items per page
return Person.getAll({ pageIndex: 1, pageSize: 10 }).items
  1. 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