预设对象
id
uuid
预设的主键。
bookmark
string
书签的标题。 如果此值为 null
,则将其视为预设而不是书签。
user
many-to-one
此预设适用于用户。 多对一到 users。
role
many-to-one
此预设适用的角色。 多对一到 users。
collection
string
此预设适用于集合。
search
string
预设中使用的搜索查询。
filters
array
预设中使用的过滤器。
layout
string
此预设中使用的布局。
layout_query
object
布局使用的项目查询。 此结构基于使用的布局。
layout_options
object
布局使用的选项。 此结构基于使用的布局。
{
"id": 39,
"bookmark": null,
"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
"role": null,
"collection": "directus_activity",
"search": null,
"filters": [],
"layout": "tabular",
"layout_query": {
"tabular": {
"sort": "-timestamp",
"fields": ["action", "collection", "timestamp", "user"],
"page": 1
}
},
"layout_options": {
"tabular": {
"widths": {
"action": 100,
"collection": 210,
"timestamp": 240,
"user": 240
}
}
}
}
列出预设
列出 Directus 中存在的所有预设。
权限
此端点中返回的数据将根据用户的权限进行过滤。 例如,角色的预设, 不会返回当前用户的角色以外的其他角色。
查询参数
支持所有全局查询参数。
返回
最多包含 limit 预设对象 的数组。 如果没有可用的项目,数据 将是一个空数组。
REST API
GET /presets
SEARCH /presets
GraphQL
POST /graphql/system
type Query {
presets: [directus_presets]
}
示例
query {
presets {
id
user
}
}
检索预设
按主键列出现有预设。
查询参数
支持所有全局查询参数。
返回
返回请求的 preset object。
REST API
GET /presets/:id
示例
GET /presets/42
GraphQL
POST /graphql/system
type Query {
presets_by_id(id: ID!): directus_presets
}
示例
query {
presets_by_id(id: 42) {
id
user
}
}
创建预设
创建一个新预设。
查询参数
支持所有全局查询参数。
请求正文
部分预设对象。
返回
返回已创建预设的 预设对象。
REST API
POST /presets
示例
// POST /presets
{
"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
"layout": "cards",
"search": "Directus"
}
GraphQL
POST /graphql/system
type Mutation {
create_presets_item(data: create_directus_presets_input!): directus_presets
}
示例
mutation {
create_presets_item(data: { user: "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca", layout: "cards", search: "Directus" }) {
id
user
}
}
创建多个预设
创建多个新预设。
查询参数
支持所有全局查询参数。
请求正文
部分预设对象的数组。
返回
返回已创建预设的 预设对象。
REST API
POST /presets
示例
// POST /presets
[
{
"collection": "directus_files",
"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
"layout": "cards",
"search": "Directus"
},
{
"collection": "articles",
"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
"layout": "tabular"
}
]
GraphQL
POST /graphql/system
type Mutation {
create_presets_items(data: [create_directus_presets_input!]!): [directus_presets]
}
示例
mutation {
create_presets_items(
data: [
{
collection: "directus_files"
user: "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca"
layout: "cards"
search: "Directus"
}
{ collection: "articles", user: "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca", layout: "tabular" }
]
) {
id
user
}
}
更新预设
更新现有预设。
查询参数
支持所有全局查询参数。
请求正文
部分预设对象。
返回
返回更新预设的 预设对象。
REST API
PATCH /presets/:id
示例
// PATCH /presets/34
{
"layout": "tabular"
}
GraphQL
POST /graphql/system
type Mutation {
update_presets_item(id: ID!, data: update_directus_presets_input): directus_presets
}
示例
mutation {
update_presets_item(id: 32, data: { layout: "tabular" }) {
id
user
}
}
更新多个预设
更新多个现有预设。
查询参数
支持所有全局查询参数。
请求正文
keys
Required
您要更新的预设的主键数组。
data
Required
预设对象 的任何属性。
返回
返回更新的预设的 预设对象。
REST API
PATCH /presets
示例
// PATCH /presets
{
"keys": [15, 64],
"data": {
"layout": "tabular"
}
}
GraphQL
POST /graphql/system
type Mutation {
update_presets_items(ids: [ID!]!, data: update_directus_presets_input): [directus_presets]
}
示例
mutation {
update_presets_items(ids: [15, 64], data: { layout: "tabular" }) {
id
user
}
}
删除预设
删除现有预设。
Returns
Empty body.
REST API
DELETE /presets/:id
示例
DELETE /presets/34
GraphQL
POST /graphql/system
type Mutation {
delete_presets_item(id: ID!): delete_one
}
示例
mutation {
delete_presets_item(id: 32) {
id
}
}
删除多个预设
删除多个现有预设。
请求正文
一组预设主键
Returns
Empty body.
REST API
DELETE /presets
示例
// DELETE /presets
[15, 251, 810]
GraphQL
POST /graphql/system
type Mutation {
delete_presets_items(ids: [ID!]!): delete_many
}
示例
mutation {
delete_presets_items(ids: [15, 251, 810]) {
ids
}
}