Skip to content

fix(tables): Resolve compilation errors in table-related classes #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/tables/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@ export default class Table {
async update(updateQuery: string): Promise<void> {
await this.tablesApiClient.updateTable(this.name, this.integration,updateQuery);
}
}

/**
* Insert data into this table.
* @param {string} select - SELECT query to insert data from.
* @throws {MindsDbError} - Something went wrong inserting data into the table.
*/
async insert(select: string): Promise<void> {
await this.tablesApiClient.insertTable(this.name, this.integration, select);
}
}

}
18 changes: 12 additions & 6 deletions src/tables/tablesApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ export default abstract class TablesApiClient {
*/
abstract deleteTable(name: string, integration: string): Promise<void>;

/**
* Removes a table from its integration.
* @param {string} name - Name of the table to be removed.
* @param {string} integration - Name of the integration the table to be removed is a part of.
* @throws {MindsDbError} - Something went wrong removing the table.
*/
abstract removeTable(name: string, integration: string): Promise<void>;

/**
* Updates a table from its integration.
* @param {string} name - Name of the table to be updated.
Expand Down Expand Up @@ -84,11 +92,9 @@ export default abstract class TablesApiClient {
*
* @param filePath - The local path to the file that needs to be uploaded.
* @param fileName - The name that the file should have on the remote server after the upload.
*
* @returns A promise that resolves when the file has been successfully uploaded.
* The promise does not return any value upon success.
*
* @throws {Error} - If there is an error during the file upload process, the promise is rejected with an error message.
* * @returns A promise that resolves when the file has been successfully uploaded.
* The promise does not return any value upon success.
* * @throws {Error} - If there is an error during the file upload process, the promise is rejected with an error message.
*/
abstract uploadFile(filePath: string, fileName: string, original_file_name?: string): Promise<void>;
}
}
19 changes: 14 additions & 5 deletions src/tables/tablesRestApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ export default class TablesRestApiClient extends TablesApiClient {
}


/**
* Removes a table from its integration.
* @param {string} name - Name of the table to be removed.
* @param {string} integration - Name of the integration the table to be removed is a part of.
* @throws {MindsDbError} - Something went wrong removing the table.
*/
override async removeTable(name: string, integration: string): Promise<void> {
await this.deleteTable(name, integration);
}


/**
* Updates a table from its integration.
* @param {string} name - Name of the table to be updated.
Expand Down Expand Up @@ -149,8 +160,7 @@ export default class TablesRestApiClient extends TablesApiClient {
* @throws {MindsDbError} - Something went wrong deleting the data from the table.
*/
override async deleteFromTable(name: string, integration: string, select?: string): Promise<void> {
/**
If select parameter is not passed then entire data from the table is deleted.
/** If select parameter is not passed then entire data from the table is deleted.
*/
const sqlQuery = select ?? `DELETE FROM TABLE ${mysql.escapeId(
integration
Expand Down Expand Up @@ -214,8 +224,7 @@ export default class TablesRestApiClient extends TablesApiClient {
* @param {string} fileName - The desired name for the file once it is uploaded.
* @param {string} [original_file_name] - (Optional) The original name of the file before renaming. This is typically
* used for logging, tracking, or maintaining the original file's identity.
*
* @returns {Promise<void>} A promise that resolves when the file upload is complete. If the upload fails,
* * @returns {Promise<void>} A promise that resolves when the file upload is complete. If the upload fails,
* an error will be thrown.
*
* @throws {Error} If there is an issue with the upload, such as network errors, permission issues, or invalid file paths.
Expand Down Expand Up @@ -257,4 +266,4 @@ export default class TablesRestApiClient extends TablesApiClient {

}

}
}
Loading