Querying with "where"

The "where" parameter in the API is a special field that allows a JSON-formatted where clause to allow custom filtering of the returned data. It is simplest to show an example of how one might query this API from JavaScript:

const where = JSON.stringify({  
    'id': {  
      '$eq': id,  
    },  
  });  
const order = JSON.stringify([['createdAt', 'DESC NULLS LAST']]);  
const options = {  
    url: ``${process.env.API_URL}v1/contacts?page=1&pageSize=10&where=${encodeURIComponent(where)}&order=${encodeURIComponent(order)}``,  
    method: 'GET',  
    headers: {  
      Accept: 'application/json',  
      Authorization: ``Bearer ${access_token}``,  
    },  
 };

Additional options for the comparison include:

$eq, $gt, $gte, $lt, $lte, $ne, $like, $ilike, $in, $is $not

// $eq - exact match
{ "status": { "$eq": "active" } }

// $gt - greater than
{ "age": { "$gt": 25 } }

// $gte - greater than or equal to
{ "score": { "$gte": 80 } }

// $lt - less than
{ "price": { "$lt": 100 } }

// $lte - less than or equal to
{ "quantity": { "$lte": 50 } }

// $ne - not equal to
{ "status": { "$ne": "deleted" } }

// $like - pattern matching with wildcards (case-sensitive)
{ "name": { "$like": "John%" } }

// $ilike - pattern matching with wildcards (case-insensitive)
{ "email": { "$ilike": "%@gmail.com" } }

// $in - matches any value in the array
{ "status": { "$in": ["InProgress", "Completed"] } }

// $is - exact match, typically used for null checks
{ "deletedAt": { "$is": null } }

// $not - negation operator, reverses the condition
{ "category": { "$not": { "$in": ["spam", "trash"] } } }