Skip to content

Commit

Permalink
Use ARRAY_CONTAINS to query roles
Browse files Browse the repository at this point in the history
Jira ticket: CAMS-283
  • Loading branch information
jamesobrooks authored and btposey committed Sep 19, 2024
1 parent cd0ac3e commit fe6b6da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CosmosConfig } from '../../types/database';
import { ServerConfigError } from '../../../common-errors/server-config-error';
import { isPreExistingDocumentError } from './cosmos.helper';
import { DocumentRepository } from '../../../use-cases/gateways.types';
import { UnknownError } from '../../../common-errors/unknown-error';

export class CosmosDbRepository<T> implements DocumentRepository<T> {
protected cosmosDbClient;
Expand Down Expand Up @@ -35,7 +36,7 @@ export class CosmosDbRepository<T> implements DocumentRepository<T> {
originalError,
});
} else {
throw originalError;
throw new UnknownError(this.moduleName, { originalError });
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ export class OfficesCosmosDbRepository implements OfficesRepository {
context: ApplicationContext,
officeCode: string,
): Promise<AttorneyUser[]> {
const query = `SELECT * FROM c WHERE c.officeCode = @officeCode and c.documentType = 'OFFICE_STAFF' and ${CamsRole.TrialAttorney} IN c.roles`;
const query = `SELECT * FROM c WHERE c.officeCode = @officeCode and c.documentType = 'OFFICE_STAFF' and ARRAY_CONTAINS(c.roles, @role)`;
const querySpec = {
query,
parameters: [
{
name: '@officeCode',
value: officeCode,
},
{
name: '@role',
value: CamsRole.TrialAttorney,
},
],
};
return await this.officeStaffRepo.query(context, querySpec);
Expand Down

0 comments on commit fe6b6da

Please sign in to comment.