@@ -38,11 +38,10 @@ function mongoSchemaToSchemaAPIResponse(schema) {
3838}
3939
4040function getAllSchemas ( req ) {
41- return req . config . database . collection ( '_SCHEMA' )
42- . then ( coll => coll . find ( { } ) . toArray ( ) )
43- . then ( schemas => ( { response : {
44- results : schemas . map ( mongoSchemaToSchemaAPIResponse )
45- } } ) ) ;
41+ return req . config . database . adaptiveCollection ( '_SCHEMA' )
42+ . then ( collection => collection . find ( { } ) )
43+ . then ( schemas => schemas . map ( mongoSchemaToSchemaAPIResponse ) )
44+ . then ( schemas => ( { response : { results : schemas } } ) ) ;
4645}
4746
4847function getOneSchema ( req ) {
@@ -152,7 +151,7 @@ function deleteSchema(req) {
152151 throw new Parse . Error ( Parse . Error . INVALID_CLASS_NAME , Schema . invalidClassNameMessage ( req . params . className ) ) ;
153152 }
154153
155- return req . config . database . collection ( req . params . className )
154+ return req . config . database . adaptiveCollection ( req . params . className )
156155 . then ( collection => {
157156 return collection . count ( )
158157 . then ( count => {
@@ -161,19 +160,19 @@ function deleteSchema(req) {
161160 }
162161 return collection . drop ( ) ;
163162 } )
164- . then ( ( ) => {
165- // We've dropped the collection now, so delete the item from _SCHEMA
166- // and clear the _Join collections
167- return req . config . database . collection ( '_SCHEMA' )
168- . then ( coll => coll . findAndRemove ( { _id : req . params . className } , [ ] ) )
169- . then ( doc => {
170- if ( doc . value === null ) {
171- //tried to delete non-existent class
172- return Promise . resolve ( ) ;
173- }
174- return removeJoinTables ( req . config . database , doc . value ) ;
175- } ) ;
176- } )
163+ } )
164+ . then ( ( ) => {
165+ // We've dropped the collection now, so delete the item from _SCHEMA
166+ // and clear the _Join collections
167+ return req . config . database . collection ( '_SCHEMA' )
168+ . then ( coll => coll . findAndRemove ( { _id : req . params . className } , [ ] ) )
169+ . then ( doc => {
170+ if ( doc . value === null ) {
171+ //tried to delete non-existent class
172+ return Promise . resolve ( ) ;
173+ }
174+ return removeJoinTables ( req . config . database , doc . value ) ;
175+ } ) ;
177176 } )
178177 . then ( ( ) => {
179178 // Success
0 commit comments