This repository was archived by the owner on May 25, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 166
Support additional string/primitive query values #53
Copy link
Copy link
Open
Description
truefalsenull"true""false""null"
These are all valid JSON values, but can't all be queried at present. Right now, true and false are being cast to their primitive types when supplied as string queries (and null is not):
q=booleanField1:true,booleanField2:false
Lines 84 to 85 in 6781bd2
| if (value == 'true') query['data.' + key] = true; | |
| else if (value == 'false') query['data.' + key] = false; |
I think it might be better to treat these non-string primitive values the way that numbers are being treated, but as special cases:
q=booleanField1:=true,booleanField2:=false,fieldWithNoValue:=null
Line 71 in 6781bd2
| else if (value.startsWith('=')) query['data.' + key] = +val; |
I haven't worked with mongo in a long time, so I'm not sure about the exact syntax, but something like
else if (value.startsWith('=')) {
if (val === 'true') query['data.' + key] = true;
else if (val === 'false') query['data.' + key] = false;
else if (val === 'null') query['data.' + key] = null;
else query['data.' + key] = +val;
}and then you could just remove the code from lines 84–85 above.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels