executeQuery

Understanding the executeQuery Method

executeQuery(query: Query, model: Model): Promise<SQLResult>

Description: Generates and executes an SQL query based on the provided model and query object.

  • Parameters:

    • query (Query): A Query object representing the SQL query to execute.

    • model (Model): A Model object representing the data model.

  • Returns:

    • A Promise that resolves to an SQLResult object or rejects with an SQLError.

Example:

client.executeQuery({
  columns: ["Album Title"],
  filters: [
    {
      column: "ArtistId",
      operator: "=",
      value: 1
    }
  ],
  limit: 10
}, {
  id: "1",
  name: "ChinookModel",
  connection: {
    id: "2",
    name: "Chinook",
    host: "localhost",
    port: 5432,
    user: "postgres",
    password: "test",
    database: "chinook",
    type: DatabaseType.POSTGRES
  },
  tables: [
    {
      id: "1",
      dbName: "album",
      name: "Album",
      columns: [
        {
          id: "title",
          dbName: "title",
          name: "Album Title",
          dataType: ColumnDataType.STRING
        }
      ]
    }
  ],
  joins: [],
  formulas: [],
  filters: []
}).then((result) => {
  console.log(result);
}).catch((error) => {
  console.error(error);
});

Last updated