Exclude null itens from aggregation


I'm trying to do an aggregation like that;

 map['sub_menu'] ||= []
                checkedFieldSubMenu = {
                    'sub_menu_id' => event.get('sub_menu_id'),
                    'cms_menu_name' => event.get('sub_menu_name'),
                    'description' => event.get('sub_menu_description'),
                    'label_value' => event.get('sub_menu_label_value'),
                    'link_url' => event.get('sub_menu_link_url'),
                if ! map['sub_menu'].include?(checkedFieldSubMenu)
                        map['sub_menu'] << checkedFieldSubMenu

Its works pretty well, except when my checkFieldSubMenu contains null values like this;

 "parent_id": null,
                "sub_menu": [
                        "description": null,
                        "cms_menu_name": null,
                        "label_value": null,
                        "link_url": null,
                        "sub_menu_id": null

Any tips to do not create sub_menu when sub_menu_id is null ?

Ty for now

Wrap most of the code in

if event.get('sub_menu_id')
1 Like

Thank you very much!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.