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): AQuery
object representing the SQL query to execute.model
(Model): AModel
object representing the data model.
Returns:
A
Promise
that resolves to anSQLResult
object or rejects with anSQLError
.
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