I have a scenario in nodeJS.
I have an object which contains number of elements and array
var Obj = {
count: 3,
items: [{
"organizationCode": "FP1",
"organizationName": "FTE Process Org"
},
{
"organizationCode": "T11",
"organizationName": "FTE Discrete Org"
},
{
"organizationCode": "M1",
"organizationName": "Seattle Manufacturing"
}
]
};
The scenario is like this. I have to filter result based on criteria.
I have print output if either organizationCode or organizationName starts with particular character or ends with or it contains particular word.
for eg if user enters starts with M or starts with "M" below should return
{
"organizationCode": "M1",
"organizationName": "Seattle Manufacturing"
}
if user enters ends with org then
{
"organizationCode": "FP1",
"organizationName": "FTE Process Org"
}, {
"organizationCode": "T11",
"organizationName": "FTE Discrete Org"
},
and if it enters contains 11 then below should return.
{
"organizationCode": "T11",
"organizationName": "FTE Discrete Org"
},
I have thousands of record. I am looking for optimize way to get output. I am new to NodeJs so struggling to complete it.