Skip to content

Instantly share code, notes, and snippets.

@masterspambot
Last active October 20, 2015 03:24
Show Gist options
  • Save masterspambot/5b5cdacf0cb8c760ef10 to your computer and use it in GitHub Desktop.
Save masterspambot/5b5cdacf0cb8c760ef10 to your computer and use it in GitHub Desktop.
Query params filtering operators
  1. Collections:
  • $all
    • return result if ALL of elements is CONTAINED in property COLLECTION

      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,2]; RESULT: true
      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,3]; RESULT: false
      FILTER: filter[members][$all]=[1,2]; SOURCE: [3,4]; RESULT: false 
      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,3,4]; RESULT: false 
      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,2,3,4]; RESULT: true 
      [this is default operator for filtering collection properties]
      
  • $notAll
    • return result if ALL of elements are NOT CONTAINED in property COLLECTION

      FILTER: filter[members][$notAll]=[1,2]; SOURCE: [1,2]; RESULT: false
      FILTER: filter[members][$notAll]=[1,2]; SOURCE: [1,3]; RESULT: false
      FILTER: filter[members][$notAll]=[1,2]; SOURCE: [3,4]; RESULT: true 
      FILTER: filter[members][$notAll]=[1,2]; SOURCE: [1,3,4]; RESULT: false
      FILTER: filter[members][$notAll]=[1,2]; SOURCE: [1,2,3,4]; RESULT: false
      
  1. Property
  • Numeric/Date:
    • $gte
      • return result if value is GREATER OR EQUAL with property VALUE
    • $lte
      • return result if value is LOWER OR EQUAL with property VALUE
    • $gt
      • return result if value is GREATER with property VALUE
    • $lt
      • return result if value is LOWER with property VALUE
  • String:
    • $startWith
      • return result if value STARTS WITH with property VALUE
    • $endWith
      • return result if value ENDS WITH with property VALUE
    • $contain
      • return result if value CONTAINS property VALUE
    • $notContain
      • return result if value NOT CONTAINS property VALUE
  1. Property/Collections:
  • $any
    • return result if ANY of values is matched wth property VALUE

      FILTER: filter[id][$any]=[1,2]; SOURCE: 1; RESULT: true
      FILTER: filter[id][$any]=[1,2]; SOURCE: 3; RESULT: false 
      [this is default operator for filtering value properties]
      
    • return result if ANY of elements is contained in property COLLECTION

      FILTER: filter[members][$any]=[1,2]; SOURCE: [1,2]; RESULT: true
      FILTER: filter[members][$any]=[1,2]; SOURCE: [1,3]; RESULT: true
      FILTER: filter[members][$any]=[1,2]; SOURCE: [3,4]; RESULT: false 
      FILTER: filter[members][$any]=[1,2]; SOURCE: [1,3,4]; RESULT: true 
      FILTER: filter[members][$any]=[1,2]; SOURCE: [1,2,3,4]; RESULT: true 
      
  • $notAny
    • return result if ANY of values NOT is matched with property VALUE

      FILTER: filter[id][$notAny]=[1,2]; SOURCE: 1; RESULT: false
      FILTER: filter[id][$notAny]=[1,2]; SOURCE: 3; RESULT: true 
      
    • return result if ANY of elements NOT is contained in property COLLECTION

      FILTER: filter[members][$notAny]=[1,2]; SOURCE: [1,2]; RESULT: false
      FILTER: filter[members][$notAny]=[1,2]; SOURCE: [1,3]; RESULT: false
      FILTER: filter[members][$notAny]=[1,2]; SOURCE: [3,4]; RESULT: true 
      FILTER: filter[members][$notAny]=[1,2]; SOURCE: [1,3,4]; RESULT: true 
      FILTER: filter[members][$notAny]=[1,2]; SOURCE: [1,2,3,4]; RESULT: false
      
  • $eq
    • return result if value is EQUAL with property VALUE

      FILTER: filter[name][$eq]='te'; SOURCE: 'test'; RESULT: false
      FILTER: filter[name][$eq]='test'; SOURCE: 'test'; RESULT: true
      FILTER: filter[value][$eq]=1; SOURCE: 12; RESULT: false
      FILTER: filter[value][$eq]=12; SOURCE: 12; RESULT: true
      FILTER: filter[dueDate][$eq]='2015-10-19T18:39:58.857Z'; SOURCE: '2015-10-19T18:39:55.857Z'; RESULT: false
      FILTER: filter[dueDate][$eq]='2015-10-19T18:39:55.857Z'; SOURCE: '2015-10-19T18:39:55.857Z'; RESULT: true
      
    • return result if ALL of elements EQUALS with property COLLECTION

      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,2]; RESULT: true
      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,3]; RESULT: false
      FILTER: filter[members][$all]=[1,2]; SOURCE: [3,4]; RESULT: false
      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,3,4]; RESULT: false 
      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,2,3,4]; RESULT: false
      
  • $notEq
    • return result if value is NOT EQUAL with property VALUE

      FILTER: filter[name][$notEq]='te'; SOURCE: 'test'; RESULT: true
      FILTER: filter[name][$notEq]='test'; SOURCE: 'test'; RESULT: fasle
      FILTER: filter[value][$notEq]=1; SOURCE: 12; RESULT: true
      FILTER: filter[value][$notEq]=12; SOURCE: 12; RESULT: false
      FILTER: filter[dueDate][$notEq]='2015-10-19T18:39:58.857Z'; SOURCE: '2015-10-19T18:39:55.857Z'; RESULT: true
      FILTER: filter[dueDate][$notEq]='2015-10-19T18:39:55.857Z'; SOURCE: '2015-10-19T18:39:55.857Z'; RESULT: false
      
    • return result if ALL of elements NOT EQUALS with property COLLECTION

      FILTER: filter[members][$notEq]=[1,2]; SOURCE: [1,2]; RESULT: false
      FILTER: filter[members][$notEq]=[1,2]; SOURCE: [1,3]; RESULT: true
      FILTER: filter[members][$notEq]=[1,2]; SOURCE: [3,4]; RESULT: true
      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,3,4]; RESULT: true 
      FILTER: filter[members][$all]=[1,2]; SOURCE: [1,2,3,4]; RESULT: true
      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment