All Downloads are FREE. Search and download functionalities are using the official Maven repository.

reference.language.fetch.html Maven / Gradle / Ivy




    
    Fetch expressions
    
    

    
    

    
    

    
    
    
    

    


Fetch expressions

Fetch expressions are used to fetch objects from the data store.

Fetching one object

Fetching one object from the store produces an object which can then be used as an input for other constructs.
Such an expression has the form fetch one where predicate ( and/or predicate ), where predicate is a boolean expression in which any attribute can be used to filter the data.

The type of the object retrieved is the type it had the last time the object was stored (or null if no object was found).

Fetching one object with a given category

Fetch expressions can be specialized to return an object of a given user type.
The type of the variable to which the object is assigned is the specified user type.
The type of the object retrieved is the type it had the last time the object was stored (or null if no object was found).
The type is specified as follows:

Fetching multiple objects

Fetching multiple objects from the store produces a Cursor which can be used as an input for iterating constructs.
Such an expression has the form fetch all where predicate ( and/or predicate ), where predicate is a boolean expression in which any attribute can be used to filter the data.

The type of each object retrieved is the type it had the last time the object was stored.

Fetching multiple objects with a given category

Similarly to fetching one object, fetching multiple objects expressions can be specialized to return only objects of a given user type.
The item type of the cursor to which the object is assigned is the specified user type.
The type of each object retrieved is the type the object had the last time the object was stored.
The type is specified as follows:

When running the above example, you'll notice that Person "Sophie" is not returned because it is not a Member.

Searching on child fields is not supported yet (it depends heaviliy on the Store implementation capabilities).

Sorting fetched objects

When fetching multiple objects, Prompto lets you specify the order in which the objects are retrieved.
This is done by specifying one or more sort attributes, and the sort direction, as follows:

Sorting on child fields is not supported yet (it depends heaviliy on the Store implementation capabilities).

Paging results

When fetching a large number of objects, it can be convenient to only retrieve a subset of them.

This is particularly convenient when paging results in a web site.

Prompto lets you specify a slice of objects to be retrieved, as follows:

Additionally, the Cursor object returned by the fetch expression has 2 attributes: count and totalCount, which can be used to know how many objects are being returned, and how many objects in the Store satisfy the query before slicing.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy