Skip to content

Instantly share code, notes, and snippets.

@zeroonedev01
Last active June 23, 2023 09:27
Show Gist options
  • Save zeroonedev01/f4f4f59ea18fa16fdb2215ad7486e462 to your computer and use it in GitHub Desktop.
Save zeroonedev01/f4f4f59ea18fa16fdb2215ad7486e462 to your computer and use it in GitHub Desktop.

Dokumentasi Filter API

Example

filtered=[{
    "id": "fullname", // for column name
    "value": "test" // for value 
},{
    "id": "Author.fullname", 
    "value": "test"
},{
    "id": "Categories.id",
    "value": "ca6bc5d8-e843-4411-b52d-44d0c6b53263"
}]

Default

  • string
    • sql => like "%value%" or substring
      [{"id": "nama", "value": "test"}]
      
  • boolean
    • sql => = or eq(equal)
      [{"id": "isRevision", "value": false}]  // true or false
      
      or
      [{"id": "isRevision", "value": 0}]  // 1 or 0
      
  • number
    • sql => = or eq(equal)
      [{"id": "stock", "value": 10}]
      
  • date
    • sql => between startOfDay(value) and endOfDay(value)
      [{"id": "createdAt", "value": "2022-01-20"}]
      

Operators

  • Basic

    • eq => = value
      [{"id": "eq$code", "value": "AAB"}]
      
    • ne => != value
      [{"id": "ne$code", "value": "AAB"}]
      
    • is => IS NULL
      [{"id": "is$PisauId", "value": null}]
      
    • not => IS NOT TRUE
      [{"id": "not$isRevision", "value": true}]
      
  • Comparison

    • gt => > value
      • date => > endOfDay(value)
    [{"id": "gt$stock", "value": 6},{"id": "gt$createdAt", "value": "2022-01-20"}]
    
    • gte => >= value
      • date => >= startDay(value)
    [{"id": "gte$stock", "value": 6},{"id": "gte$createdAt", "value": "2022-01-20"}]
    
    • lt => < value
      • date => < startDay(value)
    [{"id": "lt$createdAt", "value": 6},{"id": "lt$createdAt", "value": "2022-01-20"}]
    
    • lte => <= value
      • date => <= endOfDay(value)
    [{"id": "lte$createdAt", "value": 6},{"id": "lte$createdAt", "value": "2022-01-20"}]
    
    • between => BETWEEN value[0] AND value[1]
      • date => BETWEEN startOfDay(value[0]) and endOfDay(value[1])
    [{"id": "between$createdAt", "value": ["2022-01-20","2022-01-25"]}]
    
    • notBetween => NOT BETWEEN value[0] AND value[1]
      • date => NOT BETWEEN startOfDay(value[0]) and endOfDay(value[1])
    [{"id": "notBetween$createdAt", "value": ["2022-01-20","2022-01-25"]}]
    
  • Other

    • in => > IN [value,value,...]
    [{"id": "in$status", "value": ["staus1","status2"]}]
    
    • notIn => NOT IN [value,value,...]
    [{"id": "notIn$status", "value": ["staus1","status2"]}]
    
    • like => LIKE 'value%' or LIKE '%value%' or LIKE '%value'
    [{"id": "like$status", "value": "%disetujui"}]
    
    • notLike => NOT LIKE 'value%' or LIKE '%value%' or LIKE '%value'
    [{"id": "notLike$status", "value": "%disetujui"}]
    
    • startsWith => LIKE 'value%'
    [{"id": "startsWith$code", "value": "SPART"}]
    
    • endsWith => LIKE '%value'
    [{"id": "endsWith$code", "value": "002"}]
    
    • substring => LIKE '%value%'
    [{"id": "substring$name", "value": "Plate"}]
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment