Datastores are AirData's conceptual way of grouping tables and data. A datastore contains information about AirData App Objects and all the data or rows stored in the AirData. Datastores are particularly useful for setting up different environments like Production and Staging. This document will serve as an overview of datastores and how they can be used. It will contain the following topics:
Datastore and Profiles
A newly created organization comes with three default pre-built datastores -- Development, QA, and a Production datastore. The pre-built datastores are then tied to newly created applications which come pre-configured with a Development, QA, and Production profile, and are automatically connected to the corresponding datastore. These pre-configured datastores and profiles enable builders to easily work with separate datastores that tie to one application. For example, when building out an application and storing a user's contact information in AirData, app builders are able to use the Development profile to test writing data back to AirData. Then when ready to test, app builders can change the profile to QA and write data to the QA datastore, and lastly when ready for production, the profile can be changed to Production to write to the Production datastore.
Profiles contain the configuration information for a published instance of an application. You can modify the profile information in Configuration Builder.
The profile is selected at the top of the Configuration Builder. To modify the data source used with a Profile. Select the profile from the dropdown at the top of Configuration Builder:
With the desired profile selected, select the Data Store and save. This will bind the datastore to the profile. When an app is deployed or previewed, it will use the associated data store.
The Datastore button in Data Builder
In Data Builder, there is a button at the top of the tree titled Datastore:
Clicking this button presents the datastore dialog box. Selecting the button at the right of a datastore presents datastore action options.
This dialog lists all of the Datastores available to your organization.
- Clone - duplicate the existing data store into a new datastore.
- Backup - create a new version of the existing datastore for backup
- Delete - remove the datastore from the organization.
To select a backup or cloned datastore, go back to Configuration Builder to select the datastore in the dropdown with the current profile selected.
App Objects binding to Data Stores
AirData App Objects are objects created within Data Builder that bundle data fields together. Once defined, AirData App Objects can be used throughout an app wherever data types are used. When an App Object is defined, the definition is stored in the Datastore.
When an AirData App Object is used to store data, the data is stored in the table. This makes Datastores an ideal place for storing configuration information for each environment.
To demonstrate this, let's create two different sets of towing services for our app. One set will be mock data used in the development environment for testing, and one set will be the data shown to the user. This approach's benefit is that there is no contact to production towing services while testing in development.
When an app is created, it comes pre-configured with a Development, QA, and Production profile that are tied to their corresponding datastores. Select the Production profile from the profile dropdown at the top of the web page. This Profile is pre-configured to point to the Production datastore.
Next, go to Data Builder. Create a new AirData App Object by clicking the + icon at the top of the tree. Name the app object "Towing Provider" and give it the properties name (Text) and phone (Phone). Enter two to three records of real towing companies and Save. A modal will appear indicating the 'TowingCompanies' App Object will be created in the Production datastore. Click Continue and Save. This will serve as the production data.
Then change the profile to the Development Profile and enter two or three records of towing companies to represent test data. Click Save. A similar modal will appear to indicate the 'TowingCompanies' App Object will be created in the development datastore. This will serve as data for testing.
Lastly, Switching between profiles will switch the data available in the Towing Provider database.
Exporting and Importing Data
Inside Data Builder, it is possible to export and import data into app Objects. This data will be stored with the Datastore. Exporting data from an AirData App Object is as simple as selecting the Object in Data Builder. There is an "Export table as CSV" button in the inspector on the right.
To import data into an AirData, format the data in a spreadsheet app in the columns match each of the AirData App Object fields. Copy the data from the spreadsheet and paste it in a new row on the destination table.
Data can also be shared and imported from an existing app object. To import an app object, in Data Builder, click on the '+' icon next to App Objects and click on Import Object.
A modal will pop up with all of the app objects in the organization that can be imported. One the app object that is to be imported is identified, click on the import button to import it to the application. Then hit Save and refresh the page to see the data appear.