@@ -76,6 +76,23 @@ function _mongoSchemaObjectFromNameFields(name: string, fields) {
76
76
return object ;
77
77
}
78
78
79
+ // Returns a type suitable for inserting into mongo _SCHEMA collection.
80
+ // Does no validation. That is expected to be done in Parse Server.
81
+ function parseFieldTypeToMongoFieldType ( { type, targetClass } ) {
82
+ switch ( type ) {
83
+ case 'Pointer' : return `*${ targetClass } ` ;
84
+ case 'Relation' : return `relation<${ targetClass } >` ;
85
+ case 'Number' : return 'number' ;
86
+ case 'String' : return 'string' ;
87
+ case 'Boolean' : return 'boolean' ;
88
+ case 'Date' : return 'date' ;
89
+ case 'Object' : return 'object' ;
90
+ case 'Array' : return 'array' ;
91
+ case 'GeoPoint' : return 'geopoint' ;
92
+ case 'File' : return 'file' ;
93
+ }
94
+ }
95
+
79
96
class MongoSchemaCollection {
80
97
_collection : MongoCollection ;
81
98
@@ -148,4 +165,8 @@ MongoSchemaCollection._TESTmongoSchemaToParseSchema = mongoSchemaToParseSchema
148
165
// into the database adapter yet. We will remove this before too long.
149
166
MongoSchemaCollection . _DONOTUSEmongoFieldToParseSchemaField = mongoFieldToParseSchemaField
150
167
168
+ // Exported because we haven't moved all mongo schema format related logic
169
+ // into the database adapter yet. We will remove this before too long.
170
+ MongoSchemaCollection . _DONOTUSEparseFieldTypeToMongoFieldType = parseFieldTypeToMongoFieldType ;
171
+
151
172
export default MongoSchemaCollection
0 commit comments