Transformation helpers in util.transform
util.transform contains helper methods that make it easier to perform
complex operations against data sources.
util.transform.toDynamoDBFilterExpression(filterObject: DynamoDBFilterObject) : string-
Converts an input string to a filter expression for use with DynamoDB. We recommend using
toDynamoDBFilterExpressionwith built-in module functions. util.transform.toElasticsearchQueryDSL(object: OpenSearchQueryObject) : string-
Converts the given input into its equivalent OpenSearch Query DSL expression, returning it as a JSON string.
Example input:
util.transform.toElasticsearchQueryDSL({ "upvotes":{ "ne":15, "range":[ 10, 20 ] }, "title":{ "eq":"hihihi", "wildcard":"h*i" } })Example output:
{ "bool":{ "must":[ { "bool":{ "must":[ { "bool":{ "must_not":{ "term":{ "upvotes":15 } } } }, { "range":{ "upvotes":{ "gte":10, "lte":20 } } } ] } }, { "bool":{ "must":[ { "term":{ "title":"hihihi" } }, { "wildcard":{ "title":"h*i" } } ] } } ] } }Note
The default operator is assumed to be AND.
util.transform.toSubscriptionFilter(objFilter, ignoredFields?, rules?): SubscriptionFilter-
Converts a
Mapinput object to aSubscriptionFilterexpression object. Theutil.transform.toSubscriptionFiltermethod is used as an input to theextensions.setSubscriptionFilter()extension. For more information, see Extensions.Note
The parameters and return statement is listed below:
Parameters
-
objFilter:SubscriptionFilterObjectA
Mapinput object that's converted to theSubscriptionFilterexpression object. -
ignoredFields:SubscriptionFilterExcludeKeysType(optional)A
Listof field names in the first object that will be ignored. -
rules:SubscriptionFilterRuleObject(optional)A
Mapinput object with strict rules that's included when you're constructing theSubscriptionFilterexpression object. These strict rules will be included in theSubscriptionFilterexpression object so that at least one of the rules will be satisfied to pass the subscription filter.
Response
Returns a
SubscriptionFilter. -
util.transform.toSubscriptionFilter(Map, List)-
Converts a
Mapinput object to aSubscriptionFilterexpression object. Theutil.transform.toSubscriptionFiltermethod is used as an input to theextensions.setSubscriptionFilter()extension. For more information, see Extensions.The first argument is the
Mapinput object that's converted to theSubscriptionFilterexpression object. The second argument is aListof field names that are ignored in the firstMapinput object while constructing theSubscriptionFilterexpression object. util.transform.toSubscriptionFilter(Map, List, Map)-
Converts a
Mapinput object to aSubscriptionFilterexpression object. Theutil.transform.toSubscriptionFiltermethod is used as an input to theextensions.setSubscriptionFilter()extension. For more information, see Extensions. util.transform.toDynamoDBConditionExpression(conditionObject)-
Creates a DynamoDB condition expression.
Subscription filter arguments
The following table explains the how the arguments of the following utilities are defined:
-
Util.transform.toSubscriptionFilter(objFilter, ignoredFields?, rules?): SubscriptionFilter