Plugin: Query Filter String Parser
Introduction
The Query Filter String Parser plugin can parse a filter part of query string into a structured object. In the version 1.0.0, the plugin only supports to parse a filter string, which follows the OData format, into a BsonDocument object that represents the MongoDB filter.
Features
Parse OData Filter String To MongoDB Filter
This feature receives an OData filter string and transforms it into a MongoDB filter which is a BsonDocument object.
Method Name: ParseODataFilterStringToMongoDBFilter
Input Filter [required]: filter string that follows the OData format.
Following the below sample:
var parameters = new Dictionary<string, object>
{
{ "Filter" , "Name eq 'Indiana Jones'" }
};
Use the Invoke method in IPluginApi to call ParseODataFilterStringToMongoDBFilter method:
IPluginApi.Invoke("CwODataUriParser Query Filter String Parser", "ParseODataFilterStringToMongoDBFilter", parameters);
Output
The method will return a BsonDocument object in Filter
field if it can parse successfully.
Otherwise, it will return error details in Error
field.
Example
var parameters = new Dictionary<string, object>
{
{ "Filter" , "Name eq 'Indiana Jones'" }
};
var pluginResult = IPluginApi.Invoke("CwODataUriParser Query Filter String Parser", "ParseODataFilterStringToMongoDBFilter", parameters);
if (pluginResult.Data.ContainsKey("Error"))
{
Log.Error("[CwODataUriParser Query Filter String Parser][ParseODataFilterStringToMongoDBFilter] {@error}", pluginResult.GetObject("Error"));
return null;
}
var filter = pluginResult.Get<BsonDocument>("Filter");
var dataFilter = DynamicFilter.Parse(filter);
Installation
Requirements
- Casewhere v2.6.0 or later.
Settings
In 1.0.0 version, the plugin only supports one setting:
- ODataParserMaxDepth: The maximum number of the recursive parsing steps that the parser can perform. Default is 100.
Example
{
"ODataParserMaxDepth": 250
}
Releases
1.0.0 - 14/07/2022
Changelog
- ParseODataFilterStringToMongoDBFilter method.
Download (login required) QueryFilterStringParser plugin v1.2.0