reapit / foundations

Foundations platform mono repo
57 stars 21 forks source link

Ability to filter Metadata records via array values #7516

Closed whanno-lsl closed 2 years ago

whanno-lsl commented 2 years ago

Is your feature request related to a problem? Please describe. Is there any way of searching for Metadata records using an array field in the metadata? i.e. say I have created a "Team" metadata entity and it contains an array of negotiatorIds. Can I find all the teams which contain a specific negotiatorId?

Describe the solution you'd like Basically I think I may need some sort of CONTAINS filter to return Metadata entities where an array contains the value(s) I am interested in.

Describe alternatives you've considered I've read the docs but haven't spotted a way to do this.

Specification

Tasks

github-actions[bot] commented 2 years ago

Thank you for raising a feature request. Feature requests will be prioritised in accordance with our roadmap, customer and developer priorities. This request will be reviewed in our weekly refinement sessions and assigned to a specific project board or column, depending on the nature of the request and the development work required. For more information on our processes, please click here

github-actions[bot] commented 2 years ago

This issue has been updated and moved to our ‘Near Term’ column (typically completed within 1 - 4 months). We have assessed the effort required and outlined a technical specification - please take the time to review this detail. When we're ready to schedule the issue, it will be assigned to the relevant board where you can continue to track its progress to completion. For more information on our processes, please click here

plittlewood-rpt commented 2 years ago

Hi @whanno-lsl - we are just QA'ing this work. Do you have any examples of metadata you already store that we could run the updated version of this service against?

whanno-lsl commented 2 years ago

Sure, we have a "maintenanceTeam" entity and would like to find the teams that a specific negotiator is a member of.

For example:

{
    "entityType": "maintenanceTeam",
    "metadata": {
        "teamName": "My New Team",
        "hidden": false,
        "teamMembers": [
            {
                "negotitatorId": "ADV"
            },
            {
                "negotitatorId": "MKT"
            }
        ]
    }
}
plittlewood-rpt commented 2 years ago

Thanks for that - glad I asked that question as I dont' think the way we've implemented it will work. It's been designed to operate on an array of values, rather than an array of objects ie

{
    "entityType": "maintenanceTeam",
    "metadata": {
        "teamName": "My New Team",
        "hidden": false,
        "teamMembers": ["ADV","MKT"]
    }
}

I'll run some tests and see if further changes are required

plittlewood-rpt commented 2 years ago

Hi @whanno-lsl - I'm afraid what you're wanting to do isn't actually possible.

Effectively you'd need to be able to do something like this:

metadata.teamMembers[*].negotiator $eq "ADV"

or this

metadata.teamMembers $contains [some object]

From your original post it did seem to suggest that your data was in the format I've posted in my previous comment, in which case the contains filter will work. What's the likelihood of remodelling your data?

whanno-lsl commented 2 years ago

Okay if it's not possible then we can look at working your suggested way. It just seems a bit limited to me but I'm no expert in this area so no problem as you've given us something to work with, thanks.

plittlewood-rpt commented 2 years ago

The $con operator has been added as above and released to production. If you still have difficulties please dome back to me