@@ -69,6 +69,7 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
6969 return Number . isInteger ( value ) ? 'integer' : 'float' ;
7070 }
7171 if ( value instanceof Date ) return 'datetime' ;
72+ if ( value && typeof value === 'object' && ( '$numberDecimal' in value || value . _bsontype === 'Decimal128' ) ) return 'decimal' ;
7273 if ( typeof value === 'object' ) return 'json' ;
7374 return 'string' ;
7475 }
@@ -89,13 +90,18 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
8990 sampleValues . set ( fullKey , value ) ;
9091 }
9192
92- if (
93- value instanceof Buffer ||
94- ( value && typeof value === 'object' && ( value as any ) . _bsontype === 'Decimal128' )
95- ) {
93+ if ( value instanceof Buffer ) {
9694 addType ( fullKey , 'json' ) ;
9795 return ;
9896 }
97+ if (
98+ value &&
99+ typeof value === 'object' &&
100+ ( '$numberDecimal' in value || value . _bsontype === 'Decimal128' )
101+ ) {
102+ addType ( fullKey , 'decimal' ) ;
103+ return ;
104+ }
99105
100106 if (
101107 value &&
@@ -104,9 +110,10 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
104110 ! ( value instanceof Date )
105111 ) {
106112 addType ( fullKey , 'json' ) ;
107- } else {
108- addType ( fullKey , detectType ( value ) ) ;
113+ return
109114 }
115+
116+ addType ( fullKey , detectType ( value ) ) ;
110117 } ) ;
111118 }
112119
@@ -117,7 +124,7 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
117124 return Array . from ( fieldTypes . entries ( ) ) . map ( ( [ name , types ] ) => {
118125 const primaryKey = name === '_id' ;
119126
120- const priority = [ 'datetime' , 'date' , 'integer' , 'float' , 'boolean' , 'json' , 'string' ] ;
127+ const priority = [ 'datetime' , 'date' , 'integer' , 'float' , 'boolean' , 'json' , 'decimal' , ' string'] ;
121128
122129 const matched = priority . find ( t => types . has ( t ) ) || 'string' ;
123130
@@ -129,8 +136,8 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
129136 datetime : 'DATETIME' ,
130137 date : 'DATE' ,
131138 json : 'JSON' ,
139+ decimal : 'DECIMAL' ,
132140 } ;
133-
134141 return {
135142 name,
136143 type : typeMap [ matched ] ?? 'STRING' ,
0 commit comments