Creating records

Once a database exists, the next step is to insert some data into the database. You can do this by creating a flow and using a component to insert the data.

This tutorial uses a to-do list management application as an example to demonstrate how to create a record in the database.

Prerequisites

Step 1: Create a flow

  1. Create an HTTP Request flow.

    1. In the Explorer pane, click Create new.
    2. Select Flow.
    3. Type Insert Task.
    4. Tap the Return key.
    5. When a dialog appears, select HTTP Request.
  2. Open the Start component.

  3. From the Method dropdown, select POST.

  4. In the URL field, enter /task.

  5. From the Input Type dropdown, select Json.

  6. Copy the following JSON Schema into the Input Schema field:

    {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "isComplete": {
          "type": "boolean"
        }
      }
    }
    
  7. Click the X icon to close the component.

  8. Click Save.

Step 2: Add an "Insert" component to the flow

  1. Drag an Insert component into the Insert Task flow.
  2. Select the component to open it.
  3. From the Table dropdown, select Todo > Tasks.
  4. Alongside the Id field, click the X icon.
  5. For the Name field's Source field, select Start > Body:name.
  6. For the IsComplete field's Source field, select Start > Body:isComplete.
  7. Click the X icon to close the component.
  8. Click Save.

Step 3: Add an "End" component to the flow

  1. Drag an End component into the Insert Task flow.
  2. Select the component to open it.
  3. From the Status Code dropdown, select 200 OK.
  4. From the Content Type dropdown, select application/json.
  5. In the Body field, select Insert > Data.
  6. Click the X icon to close the component.
  7. Click Save.

Step 4: Run the flow

  1. Open the Run panel.

  2. Copy the following JSON into the Body field:

    {
      "name": "Walk the dog"
    }
    
  3. Click Run.

Navigate to the database to see the inserted data.

Tip: If a database table has a large amount of records, click the Filter button to filter the displayed data.