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 = {
293
293
294
294
function simplifiedSchema ( fields : SchemaAnalysisFieldsMap ) : SimplifiedSchema {
295
295
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 ) => {
297
302
return {
298
303
bsonType : type . bsonType , // Note: `Object` is replaced with `Document`.
299
304
...( isArrayType ( type ) ? {
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ import { allBSONTypesDoc } from './all-bson-types-fixture';
7
7
const docsFixture = [
8
8
{
9
9
foo : 1 ,
10
- bar : 'test'
10
+ bar : 25
11
11
} ,
12
12
{
13
13
foo : 2 ,
14
- bar : 25 ,
14
+ bar : 'test' ,
15
15
baz : true
16
16
} ,
17
17
{
You can’t perform that action at this time.
0 commit comments