validateModel

Understanding the validateModel method

validateModel(model: Model): Promise<ValidationResult>

Description: Validates a data model against the database schema.

  • Parameters:

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

  • Returns:

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

Example:

client.validateModel({
  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((validationResult) => {
  console.log(validationResult);
}).catch((error) => {
  console.error(error);
});

Last updated