-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add $field operator to compare fields #23
Conversation
Currently you can only compare fields to constants. This new operator allows you to compare fields with fields. For example playerCount < maxPlayers This is an exception to the mongodb syntax as mongodb doesn't support this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Some comments tho.
Security concern: Does this allow a client to probe a field you don't what them to? (e.g. creating a lobby with name "A" and comparing lobby name to password or something)
We haven't thought at all about access management in this library, maybe we could introduce an option to specify fields allowed. Or fields disallowed. (this would be for a different PR ofc).
These changes don't add any new security issues. The main security issue is tracked here: #24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more nitpick, but looks good!
Co-authored-by: Koen Bollen <[email protected]>
Co-authored-by: Koen Bollen <[email protected]>
This will enable the new `$field` operator, which will allow you to filter lobbies like: ```json { "playerCount": { "$lt": { "$field": "maxPlayers" } } } ``` See: poki/mongodb-filter-to-postgres#23
Currently you can only compare fields to constants. This new operator allows you to compare fields with fields.
For example
playerCount < maxPlayers
This is an exception to the mongodb syntax as mongodb doesn't support this without
$expr
which we don't support because it's not JSON compatible.