Lodash Connector

The Lodash Connector provides access to a subset of the Lodash utility library for data manipulation, transformation, and querying.


Operations

get

Retrieves a value from an object at a given path.

"args": [{ "user": { "name": "John" } }, "user.name"]
  • Arg 1: The source object
  • Arg 2: The path to the property (dot notation or array)
  • Arg 3 (optional): Default value if path doesn't exist

Returns:

{ "result": "John" }

set

Sets a value at a path on an object.

"args": [{ "user": {} }, "user.name", "John"]
  • Arg 1: The object to modify
  • Arg 2: The path to set
  • Arg 3: The value to set

Returns:

{ "result": { "user": { "name": "John" } } }

has

Checks if a path exists on an object.

"args": [{ "user": { "name": "John" } }, "user.name"]
  • Arg 1: The object to check
  • Arg 2: The path to check

Returns:

{ "result": true }

pick

Creates an object with only the specified properties.

"args": [{ "name": "John", "age": 30, "email": "[email protected]" }, ["name", "age"]]
  • Arg 1: The source object
  • Arg 2: Array of property names to pick

Returns:

{ "result": { "name": "John", "age": 30 } }

omit

Creates an object without the specified properties.

"args": [{ "name": "John", "age": 30, "password": "secret" }, ["password"]]
  • Arg 1: The source object
  • Arg 2: Array of property names to omit

Returns:

{ "result": { "name": "John", "age": 30 } }

merge

Deep merges objects together.

"args": [{ "user": { "name": "John" } }, { "user": { "age": 30 } }]
  • Arg 1: The destination object
  • Arg 2+: Source objects to merge

Returns:

{ "result": { "user": { "name": "John", "age": 30 } } }

keys

Returns an array of the object's keys.

"args": [{ "name": "John", "age": 30 }]
  • Arg 1: The object

Returns:

{ "result": ["name", "age"] }

values

Returns an array of the object's values.

"args": [{ "name": "John", "age": 30 }]
  • Arg 1: The object

Returns:

{ "result": ["John", 30] }

cloneDeep

Creates a deep clone of a value.

"args": [{ "user": { "name": "John", "address": { "city": "NYC" } } }]
  • Arg 1: The value to clone

Returns:

{ "result": { "user": { "name": "John", "address": { "city": "NYC" } } } }

Collection Operations

filter

Filters a collection based on a predicate.

"args": [[{ "active": true, "name": "John" }, { "active": false, "name": "Jane" }], { "active": true }]
  • Arg 1: The collection to filter
  • Arg 2: The predicate (object, function, or property name)

Returns:

{ "result": [{ "active": true, "name": "John" }] }

find

Finds the first element matching a predicate.

"args": [[{ "id": 1, "name": "John" }, { "id": 2, "name": "Jane" }], { "id": 2 }]
  • Arg 1: The collection to search
  • Arg 2: The predicate (object, function, or property name)

Returns:

{ "result": { "id": 2, "name": "Jane" } }

map

Creates an array of values by running each element through an iteratee.

"args": [[{ "name": "John" }, { "name": "Jane" }], "name"]
  • Arg 1: The collection to iterate over
  • Arg 2: The iteratee (property name, object, or function)

Returns:

{ "result": ["John", "Jane"] }

orderBy

Sorts a collection by specified properties and orders.

"args": [[{ "name": "Bob", "age": 30 }, { "name": "Alice", "age": 25 }], ["age"], ["asc"]]
  • Arg 1: The collection to sort
  • Arg 2: Array of properties to sort by
  • Arg 3: Array of sort orders ("asc" or "desc")

Returns:

{ "result": [{ "name": "Alice", "age": 25 }, { "name": "Bob", "age": 30 }] }

groupBy

Groups collection elements by a specified key.

"args": [[{ "type": "a", "val": 1 }, { "type": "b", "val": 2 }, { "type": "a", "val": 3 }], "type"]
  • Arg 1: The collection to group
  • Arg 2: The property to group by

Returns:

{ "result": { "a": [{ "type": "a", "val": 1 }, { "type": "a", "val": 3 }], "b": [{ "type": "b", "val": 2 }] } }

uniqBy

Creates a duplicate-free version of a collection based on a property.

"args": [[{ "id": 1, "name": "John" }, { "id": 2, "name": "Jane" }, { "id": 1, "name": "John" }], "id"]
  • Arg 1: The collection to deduplicate
  • Arg 2: The property to determine uniqueness

Returns:

{ "result": [{ "id": 1, "name": "John" }, { "id": 2, "name": "Jane" }] }

Array Operations

flatten

Flattens an array a single level deep.

"args": [[[1, 2], [3, 4], [5]]]
  • Arg 1: The array to flatten

Returns:

{ "result": [1, 2, 3, 4, 5] }

concat

Creates a new array concatenating the initial array with additional values.

"args": [[1, 2], 3, [4, 5]]
  • Arg 1: The initial array
  • Arg 2+: Values to concatenate

Returns:

{ "result": [1, 2, 3, 4, 5] }

first

Gets the first element of an array.

"args": [[1, 2, 3, 4, 5]]
  • Arg 1: The array

Returns:

{ "result": 1 }

last

Gets the last element of an array.

"args": [[1, 2, 3, 4, 5]]
  • Arg 1: The array

Returns:

{ "result": 5 }

chunk

Splits an array into groups of the specified size.

"args": [[1, 2, 3, 4, 5], 2]
  • Arg 1: The array to chunk
  • Arg 2: The size of each chunk

Returns:

{ "result": [[1, 2], [3, 4], [5]] }

Using Context Variables

You can reference context values in args using template syntax:

"args": ["{{context.parameters.userData}}", "profile.email"]

Example with context:

Given a context where context.parameters.users contains:

[{ "id": 1, "name": "John" }, { "id": 2, "name": "Jane" }]
"args": ["{{context.parameters.users}}", { "id": 1 }]

Returns:

{ "result": { "id": 1, "name": "John" } }