I am trying to achieve to make a object from a string.
location=new%20york&start_date=2020-06-01T00%3A00&end_date=2020-06-24T23%3A59&type=ADD&actor_uuid=f4927094-a682-4817-a6e4-03f4f6cb5h62&group_uuid=a8fc84a5-ab4d-7455-ydu5-ccbbcd2ddc79&group_uuid=af372af8-6e38-40fb-9e2e-adc5425ec50c&access_name=admin
So the above is the string I am having it from front and processing it in backend want to store it in mongodb using mongoose
My request body:
{
"City": "New York",
"type": "BILLED",
"details":"location=new%20york&start_date=2020-06-01T00%3A00&end_date=2020-06-24T23%3A59&type=ADD&actor_uuid=f4927094-a682-4817-a6e4-03f4f6cb5h62&group_uuid=a8fc84a5-ab4d-7455-ydu5-ccbbcd2ddc79&group_uuid=af372af8-6e38-40fb-9e2e-adc5425ec50c&access_name=admin"
}
Expected output respose -
{
City: "New York",
type: "BILLED",
details: {
And: [
{
_id: "objectid",
field: "location",
value: "new york",
operator: "equal"
},
{
_id: "objectid",
field: "start_date",
value: "2020-06-01T00 3A00",
operator: "equal"
},
{
_id: "objectid",
field: "end_date",
value: "2020-06-24T23 3A59",
operator: "equal"
},
{
_id: "objectid",
field: "type",
value: "ADD",
operator: "equal"
},
{
_id: "objectid",
field: "actor_uuid",
value: "f4927094-a682-4817-a6e4-03f4f6cb5h62",
operator: "equal"
},
{
_id: "objectid",
field: "group_uuid",
value: "a8fc84a5-ab4d-7455-ydu5-ccbbcd2ddc79",
operator: "equal"
},
{
_id: "objectid",
field: "group_uuid",
value: "af372af8-6e38-40fb-9e2e-adc5425ec50c",
operator: "equal"
},
{
_id: "objectid",
field: "access_name",
value: "admin",
operator: "equal"
}
]
}
Where I want to store it under conditions something like above, Now How can I achieve this? Also how do I make sure and prevent sql injections?