Files
directus/docs/reference/filter-permissions-validation-structure.md
rijkvanzanten 35074d1285 Update docs
2020-10-05 12:18:18 -04:00

1.1 KiB

@TODO put this somewhere appropriate

The filter parameter, permissions, and validation all rely on a JSON structure to define the permissions:

{
	<field>: {
		<operator>: <value>
	}
}

For example:

{
	"title": {
		"_contains": "Directus"
	}
}

Relational

You can target related values by nesting the field name of the related collection under the field name of the relational field:

{
	"author": {
		"name": {
			"_eq": "Rijk"
		}
	}
}

And / Or

You can nest multiple filter objects under a _and or _or key to group filters under more advanced logical operations:

{
  "_or": [
    {
      "_and": [
        {
          "owner": {
            "_eq": "$CURRENT_USER"
          }
        },
        {
          "status": {
            "_in": [
              "published",
              "draft"
            ]
          }
        }
      ]
    },
    {
      "_and": [
        {
          "owner": {
            "_neq": "$CURRENT_USER"
          }
        },
        {
          "status": {
            "_in": [
              "published"
            ]
          }
        }
      ]
    }
  ]
}