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
toDynamoDBFilterExpression
with 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
Map
input object to aSubscriptionFilter
expression object. Theutil.transform.toSubscriptionFilter
method 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
:SubscriptionFilterObject
A
Map
input object that's converted to theSubscriptionFilter
expression object. -
ignoredFields
:SubscriptionFilterExcludeKeysType
(optional)A
List
of field names in the first object that will be ignored. -
rules
:SubscriptionFilterRuleObject
(optional)A
Map
input object with strict rules that's included when you're constructing theSubscriptionFilter
expression object. These strict rules will be included in theSubscriptionFilter
expression 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
Map
input object to aSubscriptionFilter
expression object. Theutil.transform.toSubscriptionFilter
method is used as an input to theextensions.setSubscriptionFilter()
extension. For more information, see Extensions.The first argument is the
Map
input object that's converted to theSubscriptionFilter
expression object. The second argument is aList
of field names that are ignored in the firstMap
input object while constructing theSubscriptionFilter
expression object. util.transform.toSubscriptionFilter(Map, List, Map)
-
Converts a
Map
input object to aSubscriptionFilter
expression object. Theutil.transform.toSubscriptionFilter
method 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