@@ -186,45 +186,20 @@ class MongoSchemaCollection {
186186 . then ( ( ) => mongoSchemaToParseSchema ( schema ) )
187187 . catch ( error => {
188188 if ( error . code === 11000 ) {
189- // Duplicate key error - the schema was likely created by a concurrent operation
190- // Fetch and return the existing schema instead of throwing an error
191- return this . _collection
192- . findOne ( { _id : schema . _id } )
193- . then ( existingSchema => {
194- if ( existingSchema ) {
195- return mongoSchemaToParseSchema ( existingSchema ) ;
196- }
197- // If we can't find it, throw the original duplicate error
198- throw new Parse . Error ( Parse . Error . DUPLICATE_VALUE , 'Class already exists.' ) ;
199- } ) ;
189+ //Mongo's duplicate key error
190+ throw new Parse . Error ( Parse . Error . DUPLICATE_VALUE , 'Class already exists.' ) ;
200191 } else {
201192 throw error ;
202193 }
203194 } ) ;
204195 }
205196
206197 updateSchema ( name : string , update ) {
207- return this . _collection . updateOne ( _mongoSchemaQueryFromNameQuery ( name ) , update ) . catch ( error => {
208- // Handle duplicate key errors that can occur during concurrent schema updates
209- if ( error . code === 11000 ) {
210- // Schema already exists/updated by another concurrent operation - safe to ignore
211- return ;
212- }
213- throw error ;
214- } ) ;
198+ return this . _collection . updateOne ( _mongoSchemaQueryFromNameQuery ( name ) , update ) ;
215199 }
216200
217201 upsertSchema ( name : string , query : string , update ) {
218- return this . _collection
219- . upsertOne ( _mongoSchemaQueryFromNameQuery ( name , query ) , update )
220- . catch ( error => {
221- // Handle duplicate key errors that can occur during concurrent schema upserts
222- if ( error . code === 11000 ) {
223- // Schema already exists - safe to ignore
224- return ;
225- }
226- throw error ;
227- } ) ;
202+ return this . _collection . upsertOne ( _mongoSchemaQueryFromNameQuery ( name , query ) , update ) ;
228203 }
229204
230205 // Add a field to the schema. If database does not support the field
0 commit comments