Skip to content

springexamples/spring-data-jpa-mongodb-expressions-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo application for spring-data-jpa-mongodb-expressions

  1. first run the application
  2. start sending querying as below

Example queries:

1. find all employees with last name "ibrahim" or firstname is "mostafa" and birthdate after "1990-01-01", sorting by id desc:

URL:

http://localhost:8080/search?sort=id,desc

Request body:

{
  "$or": [
    {"lastName": "ibrahim"},
    {
      "$and": [
        {"firstName": "mostafa"},
        {
          "birthDate": {"$gt": "1990-01-01"}
        }
      ]
    }
  ]
}

Screenshot:


2. find all employees with last name "ibrahim" or department name contains "sw":

URL:

http://localhost:8080/search

Request body:

{
  "lastName": "ibrahim",
  "department.name": {"$contains":  "sw"}
}


3. query using curl:

curl -XPOST -d '{"firstName": "fofo"}' -H 'content-type: application/json' http://localhost:8080/search?sort=id,desc | jq