@webbio/strapi-plugin-relation-filter

1.0.2 • Public • Published

Strapi plugin relation filter

Enables filtering for relations in the Strapi Content Manager

Plugin Config

To enable this plugin. Add it to plugins.ts

'relation-filter': {
    enabled: true,
  },

Configuration

To use custom filters in relational fields. Add the following code to your relation attribute in a schema.json file:

{
  // ...
  "pluginOptions": {
    "relation-filter": {
      "filters": {
        // Your filters: https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#filtering
      }
    }
  },
}

Example:

{
	"kind": "collectionType",
	"collectionName": "pages",
	"info": {
		"singularName": "page",
		"pluralName": "pages",
		"displayName": "Page",
		"description": ""
	},
	"options": {
		"draftAndPublish": true
	},
	"pluginOptions": {},
	"attributes": {
		"developers": {
			"type": "relation",
			"relation": "oneToMany",
			"target": "api::team-member.team-member",
			"pluginOptions": {
				"relation-filter": {
					"filters": {
						"role": {
							"$eq": "developer"
						}
					}
				}
			}
		},
		"designers": {
			"type": "relation",
			"relation": "oneToMany",
			"target": "api::team-member.team-member",
			"pluginOptions": {
				"relation-filter": {
					"filters": {
						"role": {
							"$eq": "designer"
						}
					}
				}
			}
		},
		"overig": {
			"type": "relation",
			"relation": "oneToMany",
			"target": "api::team-member.team-member",
			"pluginOptions": {
				"relation-filter": {
					"filters": {
						"role": {
							"$null": true
						}
					}
				}
			}
		}
	}
}

Readme

Keywords

none

Package Sidebar

Install

npm i @webbio/strapi-plugin-relation-filter

Weekly Downloads

14

Version

1.0.2

License

MIT

Unpacked Size

141 kB

Total Files

37

Last publish

Collaborators

  • joerismits
  • martijn-webbio
  • hayedewit
  • maikelm
  • mikewebbio
  • smdehaas
  • tomwebbio
  • fred-webbio
  • jaapwebbio
  • rowanpaul