File tree 2 files changed +12
-12
lines changed
2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ describe('schemas', () => {
175
175
expect ( response . statusCode ) . toEqual ( 400 ) ;
176
176
expect ( body ) . toEqual ( {
177
177
code : 103 ,
178
- error : 'class HASALLPOD does not exist' ,
178
+ error : 'Class HASALLPOD does not exist. ' ,
179
179
} ) ;
180
180
done ( ) ;
181
181
} ) ;
@@ -733,7 +733,7 @@ describe('schemas', () => {
733
733
//Expect _SCHEMA entry to be gone.
734
734
expect ( response . statusCode ) . toEqual ( 400 ) ;
735
735
expect ( body . code ) . toEqual ( Parse . Error . INVALID_CLASS_NAME ) ;
736
- expect ( body . error ) . toEqual ( 'class MyOtherClass does not exist' ) ;
736
+ expect ( body . error ) . toEqual ( 'Class MyOtherClass does not exist. ' ) ;
737
737
done ( ) ;
738
738
} ) ;
739
739
} ) ;
Original file line number Diff line number Diff line change @@ -45,16 +45,16 @@ function getAllSchemas(req) {
45
45
}
46
46
47
47
function getOneSchema ( req ) {
48
- return req . config . database . collection ( '_SCHEMA' )
49
- . then ( coll => coll . findOne ( { '_id' : req . params . className } ) )
50
- . then ( schema => ( { response : mongoSchemaToSchemaAPIResponse ( schema ) } ) )
51
- . catch ( ( ) => ( {
52
- status : 400 ,
53
- response : {
54
- code : 103 ,
55
- error : 'class ' + req . params . className + ' does not exist' ,
48
+ const className = req . params . className ;
49
+ return req . config . database . adaptiveCollection ( '_SCHEMA' )
50
+ . then ( collection => collection . find ( { '_id' : className } , { limit : 1 } ) )
51
+ . then ( results => {
52
+ if ( results . length != 1 ) {
53
+ throw new Parse . Error ( Parse . Error . INVALID_CLASS_NAME , `Class ${ className } does not exist.` ) ;
56
54
}
57
- } ) ) ;
55
+ return results [ 0 ] ;
56
+ } )
57
+ . then ( schema => ( { response : mongoSchemaToSchemaAPIResponse ( schema ) } ) ) ;
58
58
}
59
59
60
60
function createSchema ( req ) {
@@ -70,7 +70,7 @@ function createSchema(req) {
70
70
response : {
71
71
code : 135 ,
72
72
error : 'POST ' + req . path + ' needs class name' ,
73
- } ,
73
+ }
74
74
} ) ;
75
75
}
76
76
return req . config . database . loadSchema ( )
You can’t perform that action at this time.
0 commit comments