Skip to content

Commit 638f3bd

Browse files
committed
feature toggle
1 parent 5c93a7f commit 638f3bd

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/compass-schema/src/modules/schema-analysis.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import type {
88
SchemaField,
99
SchemaType,
1010
PrimitiveSchemaType,
11+
SchemaParseOptions,
1112
} from 'mongodb-schema';
1213
import type { DataService } from '../stores/store';
1314
import type { Logger } from '@mongodb-js/compass-logging';
15+
import { usePreference } from 'compass-preferences-model/provider';
1416

1517
// hack for driver 3.6 not promoting error codes and
1618
// attributes from ejson when promoteValue is false.
@@ -57,11 +59,17 @@ export const analyzeSchema = async (
5759
fallbackReadPreference: 'secondaryPreferred',
5860
}
5961
);
60-
const schemaAccessor = await analyzeDocuments(docs, {
61-
signal: abortSignal,
62-
storedValuesLengthLimit: 100,
63-
distinctFieldsAbortThreshold: 1000,
64-
});
62+
const enableExportSchema = usePreference('enableExportSchema');
63+
const schemaParseOptions: SchemaParseOptions = enableExportSchema
64+
? {
65+
signal: abortSignal,
66+
storedValuesLengthLimit: 100,
67+
distinctFieldsAbortThreshold: 1000,
68+
}
69+
: {
70+
signal: abortSignal,
71+
};
72+
const schemaAccessor = await analyzeDocuments(docs, schemaParseOptions);
6573
log.info(mongoLogId(1001000090), 'Schema', 'Schema analysis completed', {
6674
ns,
6775
});

0 commit comments

Comments
 (0)