Created
March 26, 2021 10:35
-
-
Save mhewedy/86c07940de76ef96a8ff1c4f879f2954 to your computer and use it in GitHub Desktop.
Create spring-data-jpa-mongodb-expressions in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let lastName = "ibrahim"; | |
let birthDate = "1981-01-03"; | |
let q = {}; | |
if (lastName) { | |
q.lastName = lastName; | |
} | |
if (birthDate) { | |
q.$and = [ | |
{birthDate: {$gt: birthDate}}, | |
{birthDate: {$lte: birthDate}} | |
]; | |
} | |
JSON.stringify(q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment