POST /query

Description: Executes the query generated from the provided Model and Query objects.

Request Body:

  • Type: JSON object containing:

    • model: A Model object representing the data model.

    • query: A Query object representing the query to execute.

Example Request:

{
  "model": {
    "id": "1",
    "name": "ChinookModel",
    "connection": {
      "id": "2",
      "name": "Chinook",
      "host": "localhost",
      "port": 5432,
      "user": "postgres",
      "password": "test",
      "database": "chinook",
      "type": "POSTGRES"
    },
    "tables": [
      {
        "id": "1",
        "dbName": "album",
        "name": "Album",
        "columns": [
          {
            "id": "title",
            "dbName": "title",
            "name": "Album Title",
            "dataType": "STRING"
          }
        ]
      }
    ],
    "joins": [],
    "formulas": [],
    "filters": []
  },
  "query": {
    "columns": ["Album Title"],
    "filters": [
      {
        "column": "ArtistId",
        "operator": "=",
        "value": 1
      }
    ],
    "limit": 10
  }
}

Response:

  • 200 OK:

    • Type: SQLResult

    • Body: A JSON object containing the query results. See Docs for more information.

  • 500 Internal Server Error:

    • Type: SQLError

    • Body: A JSON object containing detailed error messages.

CURL Example:

curl -X POST http://localhost:3000/query \
  -H "Content-Type: application/json" \
  -d '{
        "model": {
            "id": "1",
            "name": "ChinookModel",
            "connection": {
                "id": "2",
                "name": "Chinook",
                "host": "localhost",
                "port": 5432,
                "user": "postgres",
                "password": "test",
                "database": "chinook",
                "type": "POSTGRES"
            },
            "tables": [
                {
                    "id": "1",
                    "dbName": "album",
                    "name": "Album",
                    "columns": [
                        {
                            "id": "title",
                            "dbName": "title",
                            "name": "Album Title",
                            "dataType": "STRING"
                        }
                    ]
                }
            ],
            "joins": [],
            "formulas": [],
            "filters": []
        },
        "query": {
            "columns": ["Album Title"],
            "filters": [
                {
                    "column": "ArtistId",
                    "operator": "=",
                    "value": 1
                }
            ],
            "limit": 10
        }
    }'

Last updated