@@ -2540,7 +2540,7 @@ describe('schemas', () => {
2540
2540
2541
2541
it ( 'unset field in beforeSave should not stop object creation' , done => {
2542
2542
const hook = {
2543
- method : function ( req ) {
2543
+ method : function ( req ) {
2544
2544
if ( req . object . get ( 'undesiredField' ) ) {
2545
2545
req . object . unset ( 'undesiredField' ) ;
2546
2546
}
@@ -3110,6 +3110,77 @@ describe('schemas', () => {
3110
3110
} ) ;
3111
3111
} ) ;
3112
3112
3113
+ it_only_db ( 'mongo' ) (
3114
+ 'lets you add index with with pointer like structure' ,
3115
+ done => {
3116
+ request ( {
3117
+ url : 'http://localhost:8378/1/schemas/NewClass' ,
3118
+ method : 'POST' ,
3119
+ headers : masterKeyHeaders ,
3120
+ json : true ,
3121
+ body : { } ,
3122
+ } ) . then ( ( ) => {
3123
+ request ( {
3124
+ url : 'http://localhost:8378/1/schemas/NewClass' ,
3125
+ method : 'PUT' ,
3126
+ headers : masterKeyHeaders ,
3127
+ json : true ,
3128
+ body : {
3129
+ fields : {
3130
+ aPointer : { type : 'Pointer' , targetClass : 'NewClass' } ,
3131
+ } ,
3132
+ indexes : {
3133
+ pointer : { _p_aPointer : 1 } ,
3134
+ } ,
3135
+ } ,
3136
+ } ) . then ( response => {
3137
+ expect (
3138
+ dd ( response . data , {
3139
+ className : 'NewClass' ,
3140
+ fields : {
3141
+ ACL : { type : 'ACL' } ,
3142
+ createdAt : { type : 'Date' } ,
3143
+ updatedAt : { type : 'Date' } ,
3144
+ objectId : { type : 'String' } ,
3145
+ aPointer : { type : 'Pointer' , targetClass : 'NewClass' } ,
3146
+ } ,
3147
+ classLevelPermissions : defaultClassLevelPermissions ,
3148
+ indexes : {
3149
+ _id_ : { _id : 1 } ,
3150
+ pointer : { _p_aPointer : 1 } ,
3151
+ } ,
3152
+ } )
3153
+ ) . toEqual ( undefined ) ;
3154
+ request ( {
3155
+ url : 'http://localhost:8378/1/schemas/NewClass' ,
3156
+ headers : masterKeyHeaders ,
3157
+ json : true ,
3158
+ } ) . then ( response => {
3159
+ expect ( response . data ) . toEqual ( {
3160
+ className : 'NewClass' ,
3161
+ fields : {
3162
+ ACL : { type : 'ACL' } ,
3163
+ createdAt : { type : 'Date' } ,
3164
+ updatedAt : { type : 'Date' } ,
3165
+ objectId : { type : 'String' } ,
3166
+ aPointer : { type : 'Pointer' , targetClass : 'NewClass' } ,
3167
+ } ,
3168
+ classLevelPermissions : defaultClassLevelPermissions ,
3169
+ indexes : {
3170
+ _id_ : { _id : 1 } ,
3171
+ pointer : { _p_aPointer : 1 } ,
3172
+ } ,
3173
+ } ) ;
3174
+ config . database . adapter . getIndexes ( 'NewClass' ) . then ( indexes => {
3175
+ expect ( indexes . length ) . toEqual ( 2 ) ;
3176
+ done ( ) ;
3177
+ } ) ;
3178
+ } ) ;
3179
+ } ) ;
3180
+ } ) ;
3181
+ }
3182
+ ) ;
3183
+
3113
3184
it ( 'lets you add multiple indexes' , done => {
3114
3185
request ( {
3115
3186
url : 'http://localhost:8378/1/schemas/NewClass' ,
0 commit comments