Skip to content

Instantly share code, notes, and snippets.

@mhewedy
Created March 26, 2021 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhewedy/86c07940de76ef96a8ff1c4f879f2954 to your computer and use it in GitHub Desktop.
Save mhewedy/86c07940de76ef96a8ff1c4f879f2954 to your computer and use it in GitHub Desktop.
Create spring-data-jpa-mongodb-expressions in javascript
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