File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -293,7 +293,12 @@ export type SimplifiedSchema = {
293293
294294function simplifiedSchema ( fields : SchemaAnalysisFieldsMap ) : SimplifiedSchema {
295295 function finalizeSchemaFieldTypes ( types : SchemaAnalysisFieldTypes ) : SimplifiedSchemaType [ ] {
296- return Object . values ( types ) . map ( ( type ) => {
296+ return Object . values ( types ) . sort (
297+ ( a : SchemaAnalysisType , b : SchemaAnalysisType ) => {
298+ // Sort the types by what occurs most frequent first.
299+ return b . count - a . count ;
300+ }
301+ ) . map ( ( type : SchemaAnalysisType ) => {
297302 return {
298303 bsonType : type . bsonType , // Note: `Object` is replaced with `Document`.
299304 ...( isArrayType ( type ) ? {
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ import { allBSONTypesDoc } from './all-bson-types-fixture';
77const docsFixture = [
88 {
99 foo : 1 ,
10- bar : 'test'
10+ bar : 25
1111 } ,
1212 {
1313 foo : 2 ,
14- bar : 25 ,
14+ bar : 'test' ,
1515 baz : true
1616 } ,
1717 {
You can’t perform that action at this time.
0 commit comments