@@ -38,11 +38,10 @@ function mongoSchemaToSchemaAPIResponse(schema) {
38
38
}
39
39
40
40
function 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 } } ) ) ;
46
45
}
47
46
48
47
function getOneSchema ( req ) {
@@ -152,7 +151,7 @@ function deleteSchema(req) {
152
151
throw new Parse . Error ( Parse . Error . INVALID_CLASS_NAME , Schema . invalidClassNameMessage ( req . params . className ) ) ;
153
152
}
154
153
155
- return req . config . database . collection ( req . params . className )
154
+ return req . config . database . adaptiveCollection ( req . params . className )
156
155
. then ( collection => {
157
156
return collection . count ( )
158
157
. then ( count => {
@@ -161,19 +160,19 @@ function deleteSchema(req) {
161
160
}
162
161
return collection . drop ( ) ;
163
162
} )
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
+ } ) ;
177
176
} )
178
177
. then ( ( ) => {
179
178
// Success
0 commit comments