Record types
Structure and link an app's data
A record type is a data set that an app in Middle will sync and store. This data is then available for use in workflows to build logic and map to other apps.


Attributes are the data fields within a record. Within a record type, you build out the attributes for that data. When adding a new attribute you will need to define the attribute type. There are eight attribute types: primary id, foreign key, string, number, ISO Date, ISO Datetime, Boolean, and Array. In the key column, you will want to enter the field name as it appears in the source system's API, database, etc. For example, primary_phone would represent the user's phone number. You are then able to provide any title or description you'd like to represent this attribute. To accommodate embedded data, Middle allows you to build out arrays within records.
Building out the attributes on a record type

Foreign keys

Foreign keys allow you to relate one record type with another. For example, a sale can be connected to the user who made that purchase. Foreign keys are crucial to building apps that are useful in workflows.
Connnecting check-in data to the associated user record via a foreign key
With foreign keys, you can also generate related record lookups. Related record lookups enable two functions:
  1. 1.
    They allow you to view all records associated with a single record as an array in a workflow. For example, you can view an array of all the purchases Middle has synced for a single user.
  2. 2.
    They enable the ability to view related records in a single record's history. For example, when you view a user's record in an account's app connection, you can tab over to all the check-ins Middle has synced for that user and see the workflows run on those check-ins.
Accessing all of a user's synced check-ins via a workflow
To create a related record lookup go to the record type of the data you want the related record lookup for. In the foreign key of the record type the array of data should connect to, enter the plural name of the original record type. So, if you want to see all the check-ins synced for a user, go to the check-in record type in the app development portal, scroll to the foreign key attribute that connects to the related user, and under the related name type in "checkins." What you type in will reflect the syntax of the record type name.
Creating a related record lookup between check-ins and user
Please be careful creating related record lookups between large data sets and highly centralized record types. For example, a related record lookup from check-ins to the location the check-ins occurred at. This will create massive arrays of possibly millions of records and will likely cause your workflows to crash.


Once you've set up a record type's attributes, you will then need to develop a way to grab this from the source system. There are three types of syncs that can be developed in Middle: recent record lookup, primary ID lookup, and complete transfer. You can use any combination of these syncs to grab data for a record type. All of these syncs come with their own intricacies, but all accommodate in-browser coding to allow you to easily develop an integration within Middle's infrastructure. All coding is done in Python script.
When Middle syncs a record from an external source, if it finds a record, it compares the new record to the old. If the new record is different, it updates the existing record in the Middle database. If the record in the database is not found, it is inserted into the Middle database.
Configuring and coding a recent record poll sync

Recent record poll syncs

Recent record lookups run throughout the day and grab recently updated or created data. They are the best way to get a reliable feed of data to ensure your Middle data is correct and to perform workflows as records are updated and created. These types of syncs generally run off of a last modified datetime filter in the source system. When creating a recent record lookup, you are able to determine how frequently Middle will grab data and how much overlap there will be between syncs. This means that if Middle is syncing every 15 minutes, you can set an overlap of 45 minutes to look at the past hour of data. This helps to pick up anything that was missed on the previous sync.

Primary ID lookups

When Middle grabs data via a recent record lookup or complete transfer, primary ID lookups allow Middle to also get data for any related records. For example, if Middle synced a sale record with an associated user, then a primary ID lookup would grab that user's data. Primary ID lookups ensure that Middle has all the data it needs to execute workflows.

Complete transfers

Complete transfer simply allows you to grab all data from a data source or endpoints. Complete transfers are best suited for small data sets from which you need to have all data. On the account side, complete transfers can be set up to just run when triggered by an ad-hoc sync or they can be toggled on and run automatically at a defined interval.