CognxSafeTrack commited on
Commit
ffddff2
·
1 Parent(s): 7098b31

fix: exempt Organization model from tenant isolation

Browse files
Files changed (1) hide show
  1. packages/database/src/extension.ts +4 -2
packages/database/src/extension.ts CHANGED
@@ -5,10 +5,12 @@ export const createTenantExtension = (explicitOrganizationId?: string) => {
5
  return {
6
  query: {
7
  $allModels: {
8
- async $allOperations({ operation, args, query }: any) {
9
  const organizationId = explicitOrganizationId || getOrganizationId();
10
 
11
- if (!organizationId) {
 
 
12
  return query(args);
13
  }
14
 
 
5
  return {
6
  query: {
7
  $allModels: {
8
+ async $allOperations({ model, operation, args, query }: any) {
9
  const organizationId = explicitOrganizationId || getOrganizationId();
10
 
11
+ // 🚨 EXCEPTION: Certain models should never be filtered by organizationId
12
+ const EXCLUDED_MODELS = ['Organization', 'TrainingData'];
13
+ if (EXCLUDED_MODELS.includes(model) || !organizationId) {
14
  return query(args);
15
  }
16