6.3.3. Constructing Queries

The openidm.query function enables you to query OpenIDM resource objects for reconciliation processes and workflows. Query syntax is openidm.query(id, params), where id specifies the object on which the query should be performed and params provides the parameters that are passed to the query. For example:

var params = {
    'query' : {
        'Equals': {
            'field' : 'uid',
            'values' : [
                id
            ]
        }
    }
};
var results = openidm.query("system/ScriptedSQL/account", params)
            

OpenIDM supports nine query filters and a range of keywords that can be applied to these filters. Each filter takes a field and a list as value. The following filters are supported:

Attribute Operations

Equals Filter

Determines whether the resource contains an attribute that matches a specific attribute value.

Returns true if the object satisfies all selection criteria of the filter, otherwise returns false.

For example:

{
    "Equals":{
        "field":"lastname",
            "values":[
                "Doe"
            ]
    }
}
                        
ContainsAllValues Filter

Determines whether the external resource contains an attribute that has the same name as, and contains all of the values of, the attribute placed into the filter.

Returns true if the object satisfies all the selection criteria of the filter, otherwise returns false.

Comparable Attribute Operations

Compares single-value attributes to a given filter.

GreaterThan Filter

Determines whether the attribute value of the resource object is greater than the one provided in the filter.

Returns true if the object value is greater, otherwise returns false.

GreaterThanOrEqual Filter

Determines whether the attribute value of the resource object is greater than or equal to the one provided in the filter.

Returns true if the object value is greater than or equal, otherwise returns false.

LessThan Filter

Determines whether the attribute value of the resource object is less than the one provided in the filter.

Returns true if the object value is less, otherwise returns false.

LessThanOrEqual Filter

Determines whether the attribute value of the resource object is less than or equal to the one provided in the filter.

Returns true if the object value is less than or equal, otherwise returns false.

String Attribute Operations

Compares string values to a given filter.

StartsWith Filter

Returns attributes whose value starts with the string specified in the filter.

Contains Filter

Returns attributes whose value contains the string specified in the filter.

EndsWith Filter

Returns attributes whose value ends with the string specified in the filter.

Filter Operations

Filter operations are used to construct more complex filters by comparing two filters from the preceding section or negating filters defined in the previous section.

AND Filter

A filter that matches entries using the AND boolean operator on two filters.

Example:

{
 "query":{
   "AND":[
     {
        "Equals":{
            "field":"lastname",
            "values":[
               "Doe"
            ]
        }
     },
     {
         "Equals":{
             "field":"firstname",
             "values":[
                "John"
             ]
         }
     }
   ]
 }
}
                            
OR Filter

A filter that matches entries using the OR boolean operator on two filters.

Example:

{
  "query":{
    "OR":[
      {
        "StartsWith":{
            "field":"lastname",
            "values":[
              "A"
            ]
        }
      },
      {
        "StartsWith":{
            "field":"lastname",
            "values":[
              "B"
            ]
        }
      }
    ]
  }
}
NOT Filter

A filter that filters out matched entries by negating another filter.

Example:

{
  "query":{
    "NOT":[
      {
        "Equals":{
          "field":"lastname",
          "values":[
            "Doe"
          ]
        }
      }
    ]
  }
}