File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
packages/db-mongodb/src/queries Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,32 @@ export const sanitizeQueryValue = ({
202
202
$regex : formattedValue . replace ( / [ \\ ^ $ * + ? . ( ) | [ \] { } ] / g, '\\$&' ) ,
203
203
}
204
204
}
205
+
206
+ if ( operator === 'exists' ) {
207
+ formattedValue = formattedValue === 'true' || formattedValue === true
208
+
209
+ if ( formattedValue ) {
210
+ return {
211
+ rawQuery : {
212
+ $and : [
213
+ { [ path ] : { $exists : true } } ,
214
+ { [ path ] : { $ne : null } } ,
215
+ { [ path ] : { $ne : '' } } ,
216
+ ] ,
217
+ } ,
218
+ }
219
+ } else {
220
+ return {
221
+ rawQuery : {
222
+ $or : [
223
+ { [ path ] : { $exists : false } } ,
224
+ { [ path ] : { $eq : null } } ,
225
+ { [ path ] : { $eq : '' } } , // Treat empty string as null / undefined
226
+ ] ,
227
+ } ,
228
+ }
229
+ }
230
+ }
205
231
}
206
232
207
233
if (
You can’t perform that action at this time.
0 commit comments