Filtering¶
QueryMate provides a powerful filtering system that allows you to filter your query results using various operators.
Basic Filtering¶
To filter results, use the q
parameter in your query with the following structure:
{
"filter": {
"field": {"operator": "value"}
}
}
Available Operators¶
QueryMate supports the following filter operators:
Basic Operators¶
eq
- Equal tone
- Not equal togt
- Greater thanlt
- Less thangte
- Greater than or equal tolte
- Less than or equal tocont
- Contains (for strings)starts_with
- Starts with (for strings)ends_with
- Ends with (for strings)in
- In listnin
- Not in listis_null
- Is nullis_not_null
- Is not null
Pattern Matching Operators¶
matches
- Matches pattern using LIKEdoes_not_match
- Does not match pattern using NOT LIKEmatches_any
- Matches any of the patternsmatches_all
- Matches all of the patternsdoes_not_match_any
- Does not match any of the patternsdoes_not_match_all
- Does not match all of the patterns
Presence Operators¶
present
- Not null and not emptyblank
- Null or empty
Comparison Operators¶
lt_any
- Less than any of the valueslteq_any
- Less than or equal to any of the valuesgt_any
- Greater than any of the valuesgteq_any
- Greater than or equal to any of the valueslt_all
- Less than all of the valueslteq_all
- Less than or equal to all of the valuesgt_all
- Greater than all of the valuesgteq_all
- Greater than or equal to all of the valuesnot_eq_all
- Not equal to all of the values
String Operators¶
start
- Starts withnot_start
- Does not start withstart_any
- Starts with any of the valuesstart_all
- Starts with all of the valuesnot_start_any
- Does not start with any of the valuesnot_start_all
- Does not start with all of the valuesend
- Ends withnot_end
- Does not end withend_any
- Ends with any of the valuesend_all
- Ends with all of the valuesnot_end_any
- Does not end with any of the valuesnot_end_all
- Does not end with all of the values
Case-Insensitive Operators¶
i_cont
- Case-insensitive containsi_cont_any
- Case-insensitive contains anyi_cont_all
- Case-insensitive contains allnot_i_cont
- Case-insensitive does not containnot_i_cont_any
- Case-insensitive does not contain anynot_i_cont_all
- Case-insensitive does not contain all
Boolean Operators¶
true
- Is truefalse
- Is false
Examples¶
Equal to:
/users?q={"filter":{"name":{"eq":"John"}}}
Greater than:
/users?q={"filter":{"age":{"gt":18}}}
Multiple conditions:
/users?q={"filter":{"age":{"gt":18},"name":{"starts_with":"J"}}}
In list:
/users?q={"filter":{"status":{"in":["active","pending"]}}}
Contains:
/users?q={"filter":{"email":{"cont":"@gmail.com"}}}
Null check:
/users?q={"filter":{"deleted_at":{"is_null":true}}}
Pattern matching:
/users?q={"filter":{"name":{"matches":"John%"}}}
Case-insensitive search:
/users?q={"filter":{"name":{"i_cont":"john"}}}
Multiple value comparison:
/users?q={"filter":{"age":{"gt_any":[18,21]}}}
Relationship Filtering¶
You can also filter on related models:
/users?q={"filter":{"posts.title":{"cont":"Python"}}}