Skip to content

Commit 55d1939

Browse files
committed
feat: add accessibility code to database commands in createMany subjects
1 parent db5152f commit 55d1939

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

apps/api/src/subjects/subjects.service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class SubjectsService {
4141
});
4242
}
4343

44-
async createMany(data: CreateSubjectDto[]) {
44+
async createMany(data: CreateSubjectDto[], { ability }: EntityOperationOptions = {}) {
4545
//filter out all duplicate ids that are planned to be created via a set
4646
const noDuplicatesSet = new Set(
4747
data.map((record) => {
@@ -55,7 +55,8 @@ export class SubjectsService {
5555
const existingSubjects = await this.subjectModel.findMany({
5656
select: { id: true },
5757
where: {
58-
id: { in: subjectIds }
58+
id: { in: subjectIds },
59+
AND: [accessibleQuery(ability, 'read', 'Subject')]
5960
}
6061
});
6162

@@ -76,7 +77,8 @@ export class SubjectsService {
7677
return subjectsToCreate;
7778
}
7879
return this.subjectModel.createMany({
79-
data: subjectsToCreate
80+
data: subjectsToCreate,
81+
...accessibleQuery(ability, 'create', 'Subject')
8082
});
8183
}
8284

0 commit comments

Comments
 (0)