read

Description

Reads the data from a dataset.

Input / Parameter

NameDescriptionInput TypeDefaultOptionsRequired

dataset

The name of the dataset that is created in Services.

Text

-

-

Yes

fields

The fields to be selected from the dataset. If left blank, all fields will be selected.

Object / List

-

-

No

join

The join filters to be applied.

Object / List

-

-

No

filter

The filters to be applied.

FilterFormat

-

-

No

sort

The order to sort the records by.

Object / List

-

-

No

limit

The number of records to be returned.

Number

15

-

No

page

The pagination number.

Number

-

-

No

extra

The stored value that is passed to all the callbacks.

Any

-

-

No

fields (Object | List)

Will contain a single object, or a list of one (1) or more objects which consist of:

KeyDescriptionInput TypeRequired

dataset

The dataset to select fields from. The default value for the dataset will be the main dataset selected in the �dataset� parameter.

Text

No

field

The attribute (field) to be selected.

Text

Yes

title

The new title (alias) of the field.

Text

No

join (Object | List)

Will contain a single object, or a list of one (1) or more objects (JoinFormat) which consist of:

KeyDescriptionInput TypeDefaultOptionsRequired

type

The type of table join to execute.

Text

Inner_Join

Inner_Join, Left_Join, Right_Join

Yes

dataset

The dataset to join to the main dataset. The default value for the dataset will be the main dataset selected in the �dataset� parameter if left empty.

Text

-

-

No

filter

The filters to be applied.

FilterFormat

-

-

Yes

FilterFormat (Object)

The format used for filtering in the parameter filter.

KeyDescriptionInput TypeDefaultOptionsRequired

operator

Query operators used to filter multiple times.

Text

And

Or, And

No

data

Set of rules for another group of queries.

List

-

-

No

data (List)

The format for the parameter data in FilterFormat. Will contain a list of one (1) or more objects with the following structure (dataset, operator, value) and contain zero (0) or more objects with the same structure (FilterFormat only). This can be another FilterFormat to create grouped queries.

KeyDescriptionInput TypeDefaultOptionsRequired

dataset1

The dataset to filter or compare with another dataset.

Text

-

-

No

field1

The field in the first table to be filtered.

Text

-

-

Yes

dataset

The dataset to filter.

Text

-

-

No

field

The field to be filtered.

Text

-

-

Yes

operator

Operators to be used for specific filtering.

Text

-

Equal, Not_Equal, Is_Null, Is_Not_Null, Greater_Than, Greater_Than_Or_Equal, Less_Than, Less_Than_Or_Equal, Like, Not_Like, In, Not_In, Between, Not_Between

Yes

value

The value to perform the query, which depends on the operator.

Any

-

-

No

dataset2

The dataset to compare with the first dataset.

Text

-

-

No

field2

The matching field in the second table to be filtered.

Text

-

-

Yes

sort (Object | List)

Will contain a single object, or a list of one (1) or more objects which consist of:

KeyDescriptionInput TypeDefaultOptionsRequired

dataset

The dataset to sort. The default value for the dataset will be the main dataset selected in the �dataset� parameter.

Text

-

-

No

field

The attribute (field) of the dataset to sort.

Text

-

-

Yes

order

The order to sort the rows in the field by.

Text

Ascending

Ascending, Descending

No

Output

DescriptionOutput Type

Returns the formatted information.

Object

Object

KeyDescriptionOutput Type

success

Boolean value to denote whether the function was executed successfully.

Text

message

The message to print.

Text

data

Any additional message or data to print.

Text

Callback

callback

The action performed if this function runs successfully.

DescriptionOutput Type

Returns the list of data read from the dataset.

List

errorCallback

The action performed if this function does not run successfully.

DescriptionOutput Type

Returns an error message.

Text

Example

In this example, we will read Local Table data from the local storage.

Note: This example will only work after the user has created the dataset using `Dataset.insert` function.

Steps

  1. Create a Local Table in the services panel in the service page if there is no table created yet. For the field, add nameand title as object key with Text type.

  2. Drag a button component to a page in the mobile designer.

  3. Select the event press and drag the Dataset.read function to the event flow and fill in the parameter.

  4. Drag a Log.write as Dataset.read callback and use input on it's value param type.

Result

  1. The data should be displayed in the console.

Last updated