ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:
As you can see, I have all_data level which contains an array of objects that each one of them contains sub_data array and all_data_name and all_data_path fields.{ "name": "test1", + "all_data": [ { "sub_data": [ { "sub_name": "Test1", "sub_path": "GROUP1/Test1", "info": [ { "group": "pkgs", "values": [ "tcsh" ] }, { "group": "tcsh", "values": [ "6.13.00" ] } ] }, { "sub_name": "GROUP2", "sub_path": "GROUP2", "info": [ { "group": "pkgs", "values": [ "tcsh" ] }, { "group": "tcsh", "values": [ "6.13.00" ] } ] }, ], "all_data_name": "ROOT", "all_data_path": "/PATH/TO/ROOT" } ], "username": "erwerwcsd", "timestamp": "1564475903" }
Second report:all_data1: sub_data1: sub_name: sub1 sub_path: path/to/sub1 info: { group = "ABC", version ="4.2.1" } all_data_name: ROOT all_data_path: /PATH/TO/ROOT
Third report:all_data1: sub_data1: sub_name: sub2 sub_path: path/to/sub2 info: { group = "ABC", version = "1.5.6","4.2.1" } all_data_name: ROOT all_data_path: /PATH/TO/ROOT
Fourth report:all_data1: sub_data1: sub_name: sub1 sub_path: path/to/sub1 info: { group = "ABC", version = "1.5.6","4.2.1" } all_data_name: ROOT all_data_path: /PATH/TO/ROOT
Fifth report:all_data1: sub_data1: sub_name: sub1 sub_path: path/to/sub1 info: { group = "XYZ", version = "1.5.6","4.2.1" } all_data_name: ROOT all_data_path: /PATH/TO/ROOT
Then the merge will be as follows:all_data1: sub_data1: sub_name: sub1 sub_path: path/to/sub1 info: { group = "XYZ", version = "1.5.6","4.2.1" } all_data_name: ROOT_OTHER all_data_path: /PATH/TO/ROOT
Merge of first and third: (Explanation: will be same as the first report because we take the latest. In that case they have same all_data, same sub_data and same info level)all_data1: sub_data1: sub_name: sub1 sub_path: path/to/sub1 info: { group = "ABC", version = "4.2.1" } sub_data2: sub_name: sub2 sub_path: path/to/sub2 info: { group = "ABC", version = "1.5.6","4.2.1" } all_data_name: ROOT all_data_path: /PATH/TO/ROOT
Merge of first and fourth: (Explanation: In that case they have same all_data, same sub_data and but not same info level)all_data1: sub_data1: sub_name: sub1 sub_path: path/to/sub1 info: { group = "ABC", version ="4.2.1" } all_data_name: ROOT all_data_path: /PATH/TO/ROOT
Merge of first and fifth: (Explanation: they have different all_data_name)all_data1: sub_data1: sub_name: sub1 sub_path: path/to/sub1 info: { group = "XYZ", version = "1.5.6","4.2.1" },{ group = " +ABC", version ="4.2.1" } all_data_name: ROOT all_data_path: /PATH/TO/ROOT
Because of the multi nesting It feels like not efficient to just iterate over each block and also I'm not sure which query operators I should use for that.all_data1: sub_data1: sub_name: sub1 sub_path: path/to/sub1 info: { group = "ABC", version ="4.2.1" } all_data_name: ROOT all_data_path: /PATH/TO/ROOT all_data2: sub_data1: sub_name: sub1 sub_path: path/to/sub1 info: { group = "XYZ", version = "1.5.6","4.2.1" } all_data_name: ROOT_OTHER all_data_path: /PATH/TO/ROOT
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (OT) Perl and creating a query for MongoDB
by poj (Abbot) on Jul 30, 2019 at 12:21 UTC | |
by ovedpo15 (Pilgrim) on Jul 30, 2019 at 12:42 UTC | |
by poj (Abbot) on Jul 30, 2019 at 14:04 UTC | |
by ovedpo15 (Pilgrim) on Jul 30, 2019 at 18:01 UTC | |
by GrandFather (Saint) on Jul 30, 2019 at 21:51 UTC | |
|