Functions: Filter a Complex Array like Map
Evan Lee
Is it possible to have an array function similar to the map function (https://support.integromat.com/hc/en-us/articles/360005771833-Array-Functions) but instead of returning a simple array using a key, it would just filter the complex array?
Maybe something like filter(complex array;[key for filtering];[possible values for filtering separated by a comma]) and just returns the values of the complex array that pass the filtering.
Log In
Dan Linstedt
Would love to have this! Would also love to have PHP array functions implemented here - there are a host of array functions in PHP that make it extremely powerful.
akash.paul@integromat.com
Evan Lee: Hello Evan,
This is a feature request board, if you require assistance regarding your scenario please contact our support (https://www.integromat.com/en/ticket) or feel free to post a question to our Facebook Integromat Community group (https://www.facebook.com/groups/integromat/), where hundreds of specialists, users and fans are willing to help.
Evan Lee
Akash Paul: I'm requesting a function that is similar to the map function in terms of how it is called, but used for filtering instead.
akash.paul@integromat.com
Evan Lee: Currently map function only supports one key but you're requesting for multiple key to filter using the map function. Am I right ?
Evan Lee
Akash Paul: Hmm, not multiple keys, just multiple values to filter by on a specific key. So as an example, if I had a complex array of emails (similar to the map example in the link of my original post above), I can use filter like filter(Emails[];email;abc123@gmail.com,xyz890@gmail.com) and it would return me a complex array of Emails objects that has an email field that is either abc123@gmail.com or xyz890@gmail.com.
akash.paul@integromat.com
Evan Lee: Thank you for explaining. If I understand correctly the map function is capable of returning the same emails and then you can use it for filtering purpose. If you've having difficult implementing it please let me know.
Thanks.
Evan Lee
Akash Paul: Hi, according to the map function docs, it still does the mapping (where it returns the key after), but I'm requesting that it returns the original complex object. From the docs, the map function definition is as follows:
map (complex array; key;[key for filtering];[possible values for filtering separated by a comma])
but I would like the filter function definition to be like:
filter(complex array;[key for filtering];[possible values for filtering separated by a comma])
As an example, lets say I have a complex array of User[], where a User has the fields:
{
"email": "abc123@gmail.com",
"name": "Abc"
},
if I do use the map function, I have to provide a key to map, and a key to filter, so I use the function like map(User[];email;email;abc123@gmail.com,xyz890@gmail.com), it would return me a list of Strings of the emails that match.
but for my filter function that I'm requesting, I would use the function like filter(User[];email;abc123@gmail.com,xyz890@gmail.com), it would return me list of User objects with emails that match.