website logo
👥 Community🎯 Samples on GitHub🚦System Status
💡 Guides
🚀 Examples
🍕 Developer Reference
⚡️ Changelog
🎥 Video Library
Navigate through spaces
⌘K
Examples Overview
Setting up your solution
Jig Types
Components
Datasource
Actions
Preview
Widgets
Expressions
Aggregation
Boolean
Comparison Operators
Date & Time
Path Operators
Functional Programming
Jigx Variables
Predicate Queries
String
Docs powered by
Archbee
Actions

execute-entity

8min

Execute-entity can save, update, or delete data from a database depending on the chosen method. Each datasource type (Dynamic / SQL / REST) will also have a different syntax for updating, saving, and deleting data.

For the Dynamic datasource, values will be saved under the data option. For SQL/REST datasource, values will be saved under the functionParameters option.

This action can't be used if you are using Static Data.

Configuration options

An execute-entity action can be used in multiple areas:

  1. Under action button
  2. In action list
  3. In onPress/onChange events (if the component you are setting up has these options)
  4. In onRefresh/onFocus

The execute-entity has a goBack option which is by default set to on. That means when you run execute-entity, it will automatically return you to the previous Jig.

Examples and code snippets 

We've gone ahead and expanded the few for you. Feel free to view any others you'd like to inspect.

Execute-entity in action

Document image


In this example, execute entity is used in action with the create method. This example results in creating a new record with the First name, Last name, Email, and Phone number information. Execute entity is called by the press of the Save details button on the bottom.

Example: See the full example of execute-entity in GitHub.

execute-entity-action
|
actions:
  - children:
    - type: action.execute-entity
      options:
        title: Save details
        provider: DATA_PROVIDER_DYNAMIC
        method: create
        goBack: previous
        entity: default/form
        data:
          firstname: =@ctx.datasources.employee-detail-dynamic.firstname
          lastname: =@ctx.datasources.employee-detail-dynamic.lastname
          email: =@ctx.datasources.employee-detail-dynamic.email
          phone: =@ctx.datasources.employee-detail-dynamic.phone


Execute-entity in action list

Document image


By pressing the Save details button the execute-entity action will be followed by the go-to action.

Examples: See the full example of execute-entity in GitHub.

execute-entity-action-list
|
actions:
  - children:
      - type: action.action-list
        options:
          isSequential: true
          title: Save details
          actions:
            - type: action.execute-entity
              options:
                provider: DATA_PROVIDER_DYNAMIC
                method: create
                goBack: previous
                entity: default/form
                data:
                  firstname: =@ctx.datasources.employee-detail-dynamic.firstname
                  lastname: =@ctx.datasources.employee-detail-dynamic.lastname
                  email: =@ctx.datasources.employee-detail-dynamic.email
                  phone: =@ctx.datasources.employee-detail-dynamic.phone
            - type: action.go-to
              options:
                linkTo: ja-execute-entity-onPress


Execute-entity in onPress/onChange event

Document image


Here is the example of execute-entity in onPress/onChange event in list-item.

Examples: See the full example using onChange in GitHub. See the full example using onPress you in GitHub.

onPress
onChange
|
item:
  type: component.list-item
  options:
    title: =@ctx.current.item.firstname
    subtitle: =@ctx.current.item.lastname
    description: =(@ctx.current.item.modify = 0 ? 0 :@ctx.current.item.modify) & ' time/s changed.'
    leftElement: 
      element: avatar
      text: ''
      uri: =@ctx.current.item.photo
    onPress: 
      type: action.execute-entity
      options:
          provider: DATA_PROVIDER_LOCAL
          method: update
          goBack: previous
          entity: default/employees
          data: 
            id: =@ctx.current.item.id
            modify: =($number(@ctx.current.item.modify) + 1)


Execute-entity in onRefresh/onFocus

Here is the example of execute-entity in onRefresh/onFocus. See the full example using onRefresh in GitHub. See the full example using onFocus in GitHub.

execute-entity-onRefresh
execute-entity-onFocus
|
onFocus: 
  type: action.execute-entity
  options:
    provider: DATA_PROVIDER_DYNAMIC
    method: update
    goBack: stay
    entity: default/employees
    data: 
      id: =@ctx.datasources.employee-detail-dynamic.id
      modify: =@ctx.datasources.employee-detail-dynamic.modify >= 10 ? 1 :($number(@ctx.datasources.employee-detail-dynamic.modify) + 1)


Deleting data using execute-entity

Here is an example of deleting different data using execute-entity. There are always 2 options for how you can delete a record:

  1. Using SQL Select
  2. Using JSONata function

In the first two examples, you can see the same situation where you are deleting all the records where the name equals Jane.

The third example shows how to delete the first 3 records from your datasource.

delete-by-first-name
delete-by-fist-name-jsonata-function
delete-first-3-records
|
datasource:
  people:
    type: datasource.sqlite
    options:
      provider: DATA_PROVIDER_DYNAMIC
      entities:
        - default/people
      query: |
        SELECT
          id,
          '$.name',
          '$.surname',
          '$.address'
        FROM [default/people] LIMIT 3


actions:
  - type: 'action.execute-entity'
    options:
      goBack: stay
      entity: deafult/people
      method: delete
      provider: DATA_PROVIDER_DYNAMIC
      data:
        id: =@ctx.datasource.people.id


See also

  • Developer reference



Updated 19 Sep 2023
Did this page help you?
PREVIOUS
execute-entities
NEXT
go-back
Docs powered by
Archbee
TABLE OF CONTENTS
Configuration options
Examples and code snippets
Execute-entity in action
Execute-entity in action list
Execute-entity in onPress/onChange event
Execute-entity in onRefresh/onFocus
Deleting data using execute-entity
See also
Docs powered by
Archbee
Copyright © 2023 Jigx, Inc. All rights reserved. Terms of Service