How can I create a role-based menu where users with permission to view forms like cavoucher and puvendor will only see matched content along with the parent element? I only have the form names, which could be defined anywhere in the document.
[ {
"_id" : ObjectId("57ef642fd4f27bb41b697314"),
"menuDesc" : "Cash Module",
"formName" : "",
"subMenu1" : [
{
"menuDesc" : "Setup",
"formName" : "",
"subMenu2" : [
{
"menuDesc" : "Setup Bank Details",
"formName" : "cabank",
}
]
},
{
"menuDesc" : "Vouchers",
"formName" : "",
"subMenu2" : [
{
"menuDesc" : "Maintain Cash Voucher",
"formName" : "cavoucher",
},
{
"menuName" : "Paid Voucher",
"menuDesc" : "Maintain Paid Voucher",
"formName" : "capaidvchr",
}
]
}
]
},
{
"_id" : ObjectId("57ef6464d4f27bb41b697316"),
"menuDesc" : "Purchase Module",
"formName" : "",
"subMenu1" : [
{
"menuDesc" : "Maintain Vendors",
"formName" : "puvendor"
}
]
}]
The desired result is:
[{
"_id" : ObjectId("57ef642fd4f27bb41b697314"),
"menuDesc" : "Cash Module",
"formName" : "",
"subMenu1" : [
{
"menuDesc" : "Vouchers",
"formName" : "",
"subMenu2" : [
{
"menuDesc" : "Maintain Cash Voucher",
"formName" : "cavoucher",
}
]
}
]
},{
"_id" : ObjectId("57ef6464d4f27bb41b697316"),
"menuDesc" : "Purchase Module",
"formName" : "",
"subMenu1" : [
{
"menuDesc" : "Maintain Vendors",
"formName" : "puvendor"
}
]
}}
I am unsure at which level the value matches. Can you suggest any possible solution?