[Messaging] Delete empty threads after message deletion import (#3716)
* [Messaging] Delete empty threads after message deletion import * fix
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { DataSource } from 'typeorm';
|
||||
import { DataSource, EntityManager } from 'typeorm';
|
||||
|
||||
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
|
||||
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
|
||||
@ -77,6 +77,7 @@ export class WorkspaceDataSourceService {
|
||||
/**
|
||||
*
|
||||
* Get the schema name for a workspace
|
||||
* Note: This is assuming that the workspace only has one schema but we should prefer querying the metadata table instead.
|
||||
*
|
||||
* @param workspaceId
|
||||
* @returns string
|
||||
@ -106,4 +107,23 @@ export class WorkspaceDataSourceService {
|
||||
|
||||
return `${devId ? 'twenty_' : ''}${base36String}`;
|
||||
}
|
||||
|
||||
public async executeRawQuery(
|
||||
query: string,
|
||||
parameters: any[] = [],
|
||||
workspaceId: string,
|
||||
transactionManager?: EntityManager,
|
||||
): Promise<any> {
|
||||
if (transactionManager) {
|
||||
return await transactionManager.query(query, parameters);
|
||||
}
|
||||
const workspaceDataSource =
|
||||
await this.connectToWorkspaceDataSource(workspaceId);
|
||||
|
||||
if (workspaceDataSource) {
|
||||
return await workspaceDataSource.query(query, parameters);
|
||||
}
|
||||
|
||||
throw new Error('No data source found or transaction manager provided');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user