You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Projection Type Should handle all exclusion and inclusions
* fix tests
* remove comment
* remove test
* fields which are not in schema should be allowed
* support $slice and $elemMatch
* $slice and $elemMatch should be allowed with inclusion and exclusion queries
* feat: ✨ support dot notation and a combination of object and dot notation projection
* should not project methods inside Date type
* use replacer type
expectError(Test.find({},{name: 'ss'}));// Only 0 and 1 are allowed
162
+
expectError(Test.find({},{name: 3}));// Only 0 and 1 are allowed
163
+
expectError(Test.find({},{name: true,age: false,endDate: true,tags: 1}));// Exclusion in a inclusion projection is not allowed
164
+
expectError(Test.find({},{name: true,age: false,endDate: true}));// Inclusion in a exclusion projection is not allowed
165
+
expectError(Test.find({},{name: false,age: false,tags: false,child: {name: false},docs: {myId: false,id: true}}));// Inclusion in a exclusion projection is not allowed in nested objects and arrays
166
+
expectError(Test.find({},{tags: {something: 1}}));// array of strings or numbers should only be allowed to be a boolean or 1 and 0
167
+
Test.find({},{name: true,age: true,endDate: true,tags: 1,child: {name: true},docs: {myId: true,id: true}});// This should be allowed
168
+
Test.find({},{name: 1,age: 1,endDate: 1,tags: 1,child: {name: 1},docs: {myId: 1,id: 1}});// This should be allowed
169
+
Test.find({},{_id: 0,name: 1,age: 1,endDate: 1,tags: 1,child: 1,docs: 1});// _id is an exception and should be allowed to be excluded
170
+
Test.find({},{name: 0,age: 0,endDate: 0,tags: 0,child: 0,docs: 0});// This should be allowed
171
+
Test.find({},{name: 0,age: 0,endDate: 0,tags: 0,child: {name: 0},docs: {myId: 0,id: 0}});// This should be allowed
172
+
Test.find({},{name: 1,age: 1,_id: 0});// This should be allowed since _id is an exception
173
+
Test.find({},{someOtherField: 1});// This should be allowed since it's not a field in the schema
174
+
expectError(Test.find({},{name: {$slice: 1}}));// $slice should only be allowed on arrays
175
+
Test.find({},{tags: {$slice: 1}});// $slice should be allowed on arrays
176
+
Test.find({},{tags: {$slice: [1,2]}});// $slice with the format of [ <number to skip>, <number to return> ] should also be allowed on arrays
177
+
expectError(Test.find({},{age: {$elemMatch: {}}}));// $elemMatch should not be allowed on non arrays
178
+
Test.find({},{tags: {$elemMatch: {}}});// $elemMatch should be allowed on arrays
179
+
expectError(Test.find({},{tags: {$slice: 1,$elemMatch: {}}}));// $elemMatch and $slice should not be allowed together
180
+
Test.find({},{age: 1,tags: {$slice: 5}});// $slice should be allowed in inclusion projection
181
+
Test.find({},{age: 0,tags: {$slice: 5}});// $slice should be allowed in exclusion projection
182
+
Test.find({},{age: 1,tags: {$elemMatch: {}}});// $elemMatch should be allowed in inclusion projection
183
+
Test.find({},{age: 0,tags: {$elemMatch: {}}});// $elemMatch should be allowed in exclusion projection
184
+
expectError(Test.find({},{'docs.id': 11}));// Dot notation should be allowed and does not accept any
185
+
expectError(Test.find({},{docs: {id: '1'}}));// Dot notation should be able to use a combination with objects
186
+
Test.find({},{docs: {id: false}});// Dot notation should be allowed with valid values - should correctly handle arrays
187
+
Test.find({},{docs: {id: true}});// Dot notation should be allowed with valid values - should correctly handle arrays
188
+
Test.find({},{child: 1});// Dot notation should be able to use a combination with objects
189
+
Test.find({},{'docs.profiles': {name: 1}});// should support a combination of dot notation and objects
190
+
expectError(Test.find({},{'docs.profiles': {name: 'aa'}}));// should support a combination of dot notation and objects
/** https://stackoverflow.com/questions/58434389/typescript-deep-keyof-of-a-nested-object/58436959#58436959 for dot nested implementation it is used and then modified */
0 commit comments