How does DataStore work? - a2n-seattle/rms-app GitHub Wiki

TL;DR

Call the .query() function on DataStore to do Reads (read from the database).

  • Import the DataStore API in any file you want to do Reads (Queries) from the Database
import { DataStore } from 'aws-amplify';
{
  main {
    name
    displayName
    description
    tags
    items
  }
}

This should be the response (not exact here, just an idea):

{
  "data": {
      "main": [ 
        {
          "name": "Camera",
          "displayName": "Cameras",
          "description": "All cameras",
          "tags": ["video", "trips"],
          "items": ["AJs Camera", "John's Camera"]
        },
        {
          "name": "tripods",
          "displayName": "Tripods",
          "description": "All Tripods",
          "tags": ["video, "trips"],
          "items": ["Monopod", "Small Tripod"]
        },
      ]
  }
}

(NOT CURRENTLY SUPPORTED). Maybe we will support querying for a row in a table by the ID of that row in the future. Here is how you do it: https://docs.amplify.aws/lib/datastore/data-access/q/platform/js#querying-for-a-single-item