Skip to content

brijeshb42/querybuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON query specification and implementation for Python APIs. JSON querybuilder helps APIs to support JSON queries.

All players with jersey_no equal to 1 (jersey_no == 1):

{
    "EQ":
          { "jersey_no": 1 }
}
Condition JSON KEY Symbol JSON Query
Equal to EQ == {"EQ": {"jersey_no": 2}}
Less than LT < {"LT": {"jersey_no": 2}}
Less than or Equal to LE <= {"LE": {"jersey_no": 2}}
Greater than GT > {"GT": {"jersey_no": 2}}
Greater than or Equal to GE >= {"GE": {"jersey_no": 2}}
Not equal NE != {"NE": {"jersey_no": 2}}

IN

All players where jersey_no is in [1, 2, 3]:

{
   "IN": {
      "quanity": [1, 2, 3]
   }
}

BETWEEN

All items with quantity between 10000 and 15000

{
   "BETWEEN": {
      "quanity": [10000, 15000]
   }
}

CONTAINS_ANY

For all items where author_ids contains any of 8, 9, 10

{
   "CONTAINS_ANY": {
      "author_ids": [8, 9, 10]
   }
}

CONTAINS_ALL

For all items where author_ids contains all of 8, 9

{
   "CONTAINS_ALL": {
      "author_ids": [8, 9]
   }
}

STARTSWITH

  • For all items where title starts with Film Review:

    {
       "STARTSWITH": {
      "title": "Film Review"
       }
    }

Complex queries can be composed using OR, AND or both.

Example

For all items with quanity between 10000 and 15000 and whose author_ids contains 8(the author’s ID) (in above schema, author_ids is an ArrayField in Postgres):

{
   "AND": [
      {
         "BETWEEN": {
            "quanity": [10000, 15000]
         }
      },
      {
         "CONTAINS": {
            "author_ids": [8]
         }
      }
   ]
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages