Zaydme / strapi-plugin-multi-select

A strapi custom field for a multi select input.
https://www.npmjs.com/package/strapi-plugin-multi-select
MIT License
39 stars 21 forks source link

Cant filter with `$in` operator #27

Open AaronMcCloskey opened 8 months ago

AaronMcCloskey commented 8 months ago

I know you can use $containsi but it doesn't really achieve what I want.

Let's use this example

schema.json

"page": {
  "type": "customField",
  "options": ["My Account:my-account", "Account:account", "Account Edit:account-edit"],
  "customField": "plugin::multi-select.multi-select"
},

HTTP Request

$in

filters[page][$in]=account

Does not return any data, even if I have multiple entries that have account selected

$containsi

filters[page][$containsi]=account

Returns any entries that page value includes the account characters and not only the account value

Current Behaviour

[
    {
        "id": 1,
        "attributes": {
            "page": [
                "my-account"
            ]
        }
    },
    {
        "id": 3,
        "attributes": {
            "page": [
                "account-edit"
            ]
        }
    },
    {
        "id": 5,
        "attributes": {
            "page": [
                "account"
            ]
        }
    }
]

Expected Behaviour using $in

[
    {
        "id": 5,
        "attributes": {
            "page": [
                "account"
            ]
        }
    }
]

At the moment, I can't use this plugin due to this missing feature.

Unless I am missing something. Any help would be greatly appreciated.

Pikachews commented 4 months ago

A hacky workaround I found for this is using $containsi and wrapping the value in quotes, e.g. [$containsi]="account"

eruiz-impact commented 2 months ago

Is there a timeline for this fix? I will need to drop this plugin if this functionality doesn't exist.

avxkim commented 1 week ago

@Pikachews worked for without quotes /api/test?filters[type][$containsi]=type

i guess we won't get updates for Strapi V4...