Datastore

This functionality is in beta - please learn more here.

The Datastore allows you to create custom tables on DroneDeploy. There are two parts to creating a Datastore table:

  1. Creating the table
  2. Creating columns

Note that tables are defined by the DroneDeploy CLI.

We highly recommend that you use the CLI for App development instead of building out tables via the API.

Creating a Table

Creating a Datastore table is straightforward. You use a GraphQL mutation query as below. Then you enter in the following input values:

  1. applicationId: This is the Id of your App.
  2. name: This will be the name of your table.
  3. description: This is a description you give about the table.

Try it out with the GraphQL Explorer

Query

mutation CreateTable($input: CreateTableInput!) {
  createTable(input: $input) {
    table {
      id
      application {
        id
      }
      name
      description
    }
  }
}

Input

{
  "input": {
    "applicationId": "Application:lonvecnbfyvovfqsvbxz",
    "name": "Table Name",
    "description": "Table Description"
  }
}

Results

The results should look something like this:

{
  "data": {
    "createTable": {
      "table": {
        "id": "Table:5b6bd03d0461f4000108c777",
        "application": {
          "id": "Application:lonvecnbfyvovfqsvbxz"
        },
        "name": "Table Name",
        "description": "Table Description"
      }
    }
  }
}

Creating Columns

Your table now needs columns.

Note that we support several Column Types which you can reference here.

Creating a column is very similar to creating the table itself. You use a GraphQL mutation with the following input values:

  1. tableId: This is the Id of the table you created above.
  2. columnType: This is the type of column, you can find all of the available types here.
  3. name: This will be the name of your table column.
  4. description: Give your column a description for easier reference.

Note that certain column types have specific inputs. For example, for the TEXT column type, you can specify textLength and even whether or not you want that column to be textEncrypted.

Try it out with the GraphQL Explorer

Query

mutation CreateTableColumn($input: CreateTableColumnInput!) {
  createTableColumn(input: $input) {
    tableColumn {
      id
      name
      description
      ... on NumberColumn {
        type
      }
      ... on TextColumn {
        length
      }
    }
  }
}

Input


{
  "input": {
    "columnType": "TEXT",
    "name": "name",
    "textLength": 255,
    "textEncrypted": false,
    "tableId": "Table:5b6bd03d0461f4000108c777",
    "description": "Users name"
  }
}

Results

The results should look something like this:

{
  "data": {
    "createTableColumn": {
      "tableColumn": {
        "id": "TextColumn:5ade569b2a3c590001231bbb",
        "name": "name",
        "description": "Users name",
        "length": 255
      }
    }
  }
}

Creating Table Data

Now that you have a Datastore table, you can store your own custom data! Similar to creating a Datastore table and creating a Datastore column, you will create a GraphQL query for creating Datastore data.

The inputs to this query are as follows:

  1. externalId: This is the Id of the data that you can use to reference and retrieve it later. NOTE: There is a 36 character limit to this field.
  2. tableId: This is the Id of the table you created above.
  3. data: This is the data you want to store in stringified JSON format. Note that each Datastore table column is a JSON key. In this example, that would be the name column.

Try it out with the GraphQL Explorer

Query

mutation CreateTableData($input: CreateTableDataInput!) {
  createTableData(input: $input) {
    tableData {
      id
      application {
        id
      }
      data
      externalKey
      table {
        id
      }
    }
  }
}

Input

{
  "input": {
    "externalId": "developer@dronedeploy.com",
    "tableId": "Table:5b6bd03d0461f4000108c777",
    "data": "{ \"name\": \"DroneDeploy Developer\" }"
  }
}

Results

The results should look something like this.


{
  "data": {
    "createTableData": {
      "tableData": {
        "id": "TableData:5b5141ca09867c000116a15e",
        "application": {
          "id": "Application:lonvecnbfyvovfqsvbxz"
        },
        "data": "{\"name\": \"DroneDeploy Developer\"}",
        "externalKey": "developer@dronedeploy.com",
        "table": {
          "id": "Table:5b6bd03d0461f4000108c777"
        }
      }
    }
  }
}

Retrieving Table Data

Now let's retrieve the data that we created.

This query takes two inputs:

  1. externalKey: This is the externalId that you passed into the Datastore data creation query. In this example, this was developer@dronedeploy.com.
  2. tableId: This is the Id of the table you created above.

Try it out with the GraphQL Explorer

Query

query ($tableId: ID!, $externalKey: String!) {
  node(id: $tableId) {
    ... on Table {
      tableDatum(externalKey: $externalKey) {
        data
      }
    }
  }
}

Input

{
  "tableId": "Table:5b6bd03d0461f4000108c777",
  "externalKey": "developer@dronedeploy.com"
}

Results

The results should look something like this.

{
  "data": {
    "node": {
      "tableDatum": {
        "data": "{\"name\": \"DroneDeploy Developer\"}"
      }
    }
  }
}

results matching ""

    No results matching ""