refactor(core): Continue moving typeorm operators to repositories (no-changelog) (#8212)
Follow-up to: https://github.com/n8n-io/n8n/pull/8186
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Service } from 'typedi';
|
||||
import { DataSource, Repository, In, Not } from 'typeorm';
|
||||
import type { EntityManager, FindOptionsWhere } from 'typeorm';
|
||||
import type { EntityManager, FindOptionsSelect, FindOptionsWhere } from 'typeorm';
|
||||
import { SharedWorkflow } from '../entities/SharedWorkflow';
|
||||
import { type User } from '../entities/User';
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
@@ -125,4 +125,20 @@ export class SharedWorkflowRepository extends Repository<SharedWorkflow> {
|
||||
|
||||
return transaction.save(newSharedWorkflows);
|
||||
}
|
||||
|
||||
async findWithFields(workflowIds: string[], { fields }: { fields: string[] }) {
|
||||
return this.find({
|
||||
where: {
|
||||
workflowId: In(workflowIds),
|
||||
},
|
||||
select: fields as FindOptionsSelect<SharedWorkflow>,
|
||||
});
|
||||
}
|
||||
|
||||
async deleteByIds(transaction: EntityManager, sharedWorkflowIds: string[], user?: User) {
|
||||
return transaction.delete(SharedWorkflow, {
|
||||
user,
|
||||
workflowId: In(sharedWorkflowIds),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user