Dittofi
  • Tutorials
    • Tutorial Index
    • Quick Start
    • Dittofi Essentials
      • Part 1: Frontend terms and concepts
      • Part 2: Backend terms and concepts
      • Part 3: Connecting frontend and backend
      • Part 4: Dittofi app structure
    • Dittofi App Design
      • 🏗️App architecture 101
      • ◼️Backend app development 101
      • 🟪Frontend app development 101
      • 🔰(optional) Web developer beginner series
  • Learn Frontend
    • 👨‍💻Getting Started
      • Welcome to Dittofi
      • Intro to the Dittofi Design Studio (Frontend)
    • 🟩Pages
    • 🟪Elements
      • Types
        • Button Element
        • Div Block Element
        • Form Block Element
        • Link Block Element
        • List Element
        • Modal Box Element
        • Tabs Element
        • Columns Element
        • Image Element
      • Partials
      • Prefabs
      • Custom
    • 🟧Variables
      • Array
      • Checkbox
      • Collection
      • Collection (Custom Model)
      • Collection (System Custom Model)
      • Custom Model
      • Date
      • Datetime
      • File
      • Json
      • Number
      • Number with decimal
      • Model
      • System Custom Model
      • Text
      • UUID
    • 🟨Events
      • 🟨External
        • HTTP Request
        • Run Endpoint
      • 🟨Flow Control
        • Condition
        • Run Action
        • Loop
        • Sleep
      • 🟨Maths
        • Add
        • Divide
        • Modulus
        • Multiply
        • Subtract
      • 🟨Navigation
        • Open Page
      • 🟨Notifications
        • Alert
        • Confirm
      • 🟨Other
        • Copy To Clipboard
        • Run Custom
      • 🟨Text
        • Concat
        • Contains
        • Ends With
        • I Contains
        • I Ends With
        • I Starts With
        • LTrim
        • RTrim
        • Text To Upper
        • Text To Lower
        • Trim
        • Starts With
      • 🟨Variables
        • Set Field
        • Remove Field
      • Validate
    • 🟦CSS Layouts
      • Holy Grail Layout
      • Side Bar Layout
      • Sticky Footer Layout
      • Sticky Header Layout
      • CSS Frameworks
    • 🔲CSS Frameworks
    • Component Libraries
    • Meta Attributes
  • Learn Backend
    • 🖥️Getting Started
      • Intro to Data
      • Intro to APIs
      • Build your first custom API
      • Actions & Events
    • 🟫Back-End Actions
    • 🟩Custom Models
      • 🟩Attributes
        • Array
        • Checkbox
        • Custom Model
        • Collection (Custom Model)
        • Collection (System Custom Model)
        • Date
        • Datetime
        • File
        • Number
        • Number With Decimal
        • Json
        • Text
    • ◼️Data Models
      • Database Fundamentals
        • Database relationships
      • ◼️Columns
        • Attachment
        • Auto Increment
        • Checkbox
        • Date
        • Datetime
        • Duration
        • Email
        • Long text
        • Link to another record field
        • Number
        • Number with decimal
        • Password
        • Phone number
        • Percent
        • Price
        • Rating
        • Single select
        • Single line text
        • URL
    • 🟥Events
      • 🟦Arrays
        • Append
        • Array Pop
        • At
        • Length
        • Prepend
        • Range
      • 🟦Conversions
        • Base64 Encode
        • Base64 Decode
        • Json Decode
        • Json Encode
        • Path Escape
        • Path Unescape
        • Query Escape
        • Query String Parse
        • Query Unescape
        • To Bool
        • To Float
        • To Int
        • To Str
        • Yaml Encode
        • Yaml Decode
      • 🟦Database Requests
        • Create
        • Create Or Update
        • Delete
        • Has Record
        • Read Event
        • Update
      • 🟦External
        • HTTP Request
        • SFTP Download
        • SFTP Upload
      • 🟦Files
        • CSV Reader Event
        • CSV Writer Event
        • File Read
        • File Save
        • File Size
        • File Type
        • JSON Reader
        • PDF Generator
      • 🟦Flow Control
        • Condition
        • Loop
        • Return
        • Run Action
        • Sleep
      • 🟦Notifications
        • Send Mail
        • Connect Websocket
        • Message Websocket
      • 🟦Maths
        • Add
        • Acos
        • Acosh
        • Asin
        • Asinh
        • Atan
        • Atanh
        • Cbrt
        • Ceil
        • Divide
        • Modulus
        • Multiply
        • Subtract
      • 🟦Security
        • Compare Password
        • JWT Decode
        • JWT Encode
        • Login
        • Logout Web User
        • Password Generator
        • Random Number
      • 🟦Time
        • Add Time
        • Day
        • Format Time
        • Minute
        • Nanosecond
        • Parse Time
        • Second
        • Time In
        • Year
        • Year Day
      • 🟦Text
        • Concat
        • Contains
        • Ends With
        • Execute Template
        • I Contains
        • I Ends With
        • I Starts With
        • Starts With
        • LTrim
        • RTrim
        • Replace
        • Regex Find All String
        • Regex Find String
        • Regex Match String
        • Trim
        • Text To Lower
        • Text To Upper
        • Text To Title
        • Url Getarg
      • 🟦Other
        • Assign
        • Run Custom
        • Redirect Web Page Event
        • Render Web Template Event
    • 🟧Variables
      • Array
      • Checkbox
      • Collection
      • Collection (Custom Model)
      • Collection (System Custom Model)
      • Custom Model
      • Date
      • Datetime
      • File
      • Json
      • Number
      • Number with decimal
      • Model
      • System Custom Model
      • Text
      • UUID
    • 🟪Webservices
  • Templates
    • Two sided marketplace template
      • Introduction
        • Part I: Installing and setting up the marketplace template
        • Part II: Understanding what features are included in the marketplace template
        • Part III: Customizing your marketplace frontend without coding
        • Exploring Dittofi's marketplace API
      • Listings
        • How to create a marketplace listing
    • How to build a CRUD app
  • Third Party APIs
    • OAuth 2.0 APIs
      • Introduction To OAuth 2.0
      • Google OAuth 2.0 - PART I
      • Google OAuth 2.0 - PART II
  • Dittofi Admin
    • Your Account
      • Workspace Admin
      • Manage Billing
      • Connect a custom domain
      • How to use a discount code to Dittofi Pro
  • FAQ
    • API Generator
    • How to write custom SQL?
    • Why does my image not display?
    • How can I set up Google Analytics?
    • Exporting and deploying my frontend code
    • What is a partial and what is a prefab?
    • How to set up a basic mulit tenant app on Dittofi
    • How to write a custom endpoint in Dittofi
    • How to integrate Font Awesome into Dittofi
    • How can I set up Dittofi to run on my own private server?
    • How to add roles such as Super Admin, Admin, Manager & User
    • How to prevent duplicate records being added to the database
    • What to do when relation cannot be created because their is violating data in the referenced table
  • Change Logs
    • Dittofi Change Logs
Powered by GitBook
On this page
  • Setting up a GET Endpoint
  • Linking our GET Endpoint to an action

Was this helpful?

  1. Learn Backend
  2. Events
  3. Database Requests

Read Event

An overview of how to configure your software application to read records from inside one of your data models

PreviousHas RecordNextUpdate

Last updated 2 years ago

Was this helpful?

The read event allows you to retrieve data from one of your data models & send this data back to your endpoint. This can be useful if you want to get data out of your data model & display it to your users in a frontend user interface.

In this tutorial we cover:

  • Setting up a GET endpoint

  • Linking our GET endpoint to an action

  • Getting a filtered data set

For the purpose of this example, we will use a data model that holds different types of plants, their prices, quantity & currency.

Our goal is to set up a GET Endpoint that allows our users to get data records out of this data model whenever the endpoint is triggered.

There are two ways to do this, we can either:

  1. Build the endpoint, action & event from scratch.

In this article we will cover how to build the endpoint, action & event from scratch.

Setting up a GET Endpoint

In this section we are going to create a GET Endpoint manually to get a collection of records out of our Plant Data Model. To do this, head on over to the endpoints tab & press the "+ New Endpoint" button to create a new endpoint.

Next, we fill in the basic details for our endpoint as below.

Note, we only need to fill in the Basic options within our endpoint, since this is a GET Endpoint to get a collection of plant information & we are not sending any data to our endpoint.

Lastly, press save & close the endpoint.

Linking our GET Endpoint to an action

Next, we need to link our GET All plant data endpoint to an action. To do this, we start by heading over to the actions tab & pressing "+ New Action".

Next we give our action a name, call it "Get all plan data".

The best idea here is to give the action the same name as your endpoint, since it will make it easier to search for in the future.

Next, under our actions Advanced settings, we link our action to our endpoint. This means that whenever our GET All plant data endpoint is triggering, this will start the action running.

Notice, because we are getting data out of our Plant Data Model, we are going to want to return this data to our endpoint. To do this, we need to declare a variable within our action. This variable will sit as a placeholder waiting to store a collection of records that our action will return when run.

To create a variable within your action, go to the variables section of the action & click the "Add" button.

The variable that we are adding here is going to store all of the data returned from our Plants Data Model. This means it needs to be able to store a collection of records Plant Data Model. To configure this we (A) set the Kind to Collection, (B) set a meaningful Label & Name, (C) set the Type to Basic & (D) pick the Model Plant Data.

Lastly, we press Save to close this popup.

The final step in the configuration is to set our actions response variable to our All of plant data variable.

Testing Our GET Endpoint, Action & Event

To test our GET Endpoint, Action & Event, we need to (A) generate the code, (B) test our endpoint from within the endpoints tab & (C) check our endpoint response code & body for the collection of records from our Plants Data Model. The video below shows this process in action.

Notice that if you've configured this successfully, the response code will be set to 200 & the endpoint body will contain you plant data.

Ditto Tip: If your endpoint body is empty, but you get a 200 response code, then it is likely that your action is not sending a response variable back to your endpoint. You can double check this by reopening your Action & checking under the option Resp Variable.

Use the API Generator, see , OR

🟥
🟦
API Generator
Example Plant Data Model