|
| 1 | +summary: Update multiple Fields |
| 2 | +description: Updates the given fields in the given collection. |
| 3 | +operationId: updateFields |
| 4 | +requestBody: |
| 5 | + content: |
| 6 | + application/json: |
| 7 | + schema: |
| 8 | + type: array |
| 9 | + items: |
| 10 | + type: object |
| 11 | + properties: |
| 12 | + type: |
| 13 | + description: Directus specific data type. Used to cast values in the API. |
| 14 | + example: integer |
| 15 | + type: string |
| 16 | + field: |
| 17 | + type: string |
| 18 | + description: Unique name of the field. Field name is unique within the |
| 19 | + collection. |
| 20 | + example: id |
| 21 | + schema: |
| 22 | + type: object |
| 23 | + description: The schema info. |
| 24 | + properties: |
| 25 | + type: |
| 26 | + description: The type of the field. |
| 27 | + example: string |
| 28 | + type: string |
| 29 | + name: |
| 30 | + type: string |
| 31 | + description: The name of the field. |
| 32 | + example: title |
| 33 | + table: |
| 34 | + type: string |
| 35 | + description: The collection of the field. |
| 36 | + example: posts |
| 37 | + default_value: |
| 38 | + type: string |
| 39 | + description: The default value of the field. |
| 40 | + example: |
| 41 | + nullable: true |
| 42 | + max_length: |
| 43 | + type: integer |
| 44 | + description: The max length of the field. |
| 45 | + example: |
| 46 | + nullable: true |
| 47 | + is_nullable: |
| 48 | + type: boolean |
| 49 | + description: If the field is nullable. |
| 50 | + example: false |
| 51 | + is_primary_key: |
| 52 | + type: boolean |
| 53 | + description: If the field is primary key. |
| 54 | + example: false |
| 55 | + has_auto_increment: |
| 56 | + type: boolean |
| 57 | + description: If the field has auto increment. |
| 58 | + example: false |
| 59 | + foreign_key_column: |
| 60 | + type: string |
| 61 | + description: Related column from the foreign key constraint. |
| 62 | + example: |
| 63 | + nullable: true |
| 64 | + foreign_key_table: |
| 65 | + type: string |
| 66 | + description: Related table from the foreign key constraint. |
| 67 | + example: |
| 68 | + nullable: true |
| 69 | + comment: |
| 70 | + type: string |
| 71 | + description: Comment as saved in the database. |
| 72 | + example: |
| 73 | + nullable: true |
| 74 | + schema: |
| 75 | + type: string |
| 76 | + description: Database schema (pg only). |
| 77 | + example: public |
| 78 | + foreign_key_schema: |
| 79 | + type: string |
| 80 | + description: Related schema from the foreign key constraint (pg only). |
| 81 | + example: |
| 82 | + nullable: true |
| 83 | + meta: |
| 84 | + type: object |
| 85 | + description: The meta info. |
| 86 | + nullable: true |
| 87 | + properties: |
| 88 | + id: |
| 89 | + type: integer |
| 90 | + description: Unique identifier for the field in the `directus_fields` |
| 91 | + collection. |
| 92 | + example: 3 |
| 93 | + collection: |
| 94 | + type: string |
| 95 | + description: Unique name of the collection this field is in. |
| 96 | + example: posts |
| 97 | + field: |
| 98 | + type: string |
| 99 | + description: Unique name of the field. Field name is unique within |
| 100 | + the collection. |
| 101 | + example: title |
| 102 | + special: |
| 103 | + type: array |
| 104 | + description: Transformation flag for field |
| 105 | + example: |
| 106 | + items: |
| 107 | + type: string |
| 108 | + nullable: true |
| 109 | + system-interface: |
| 110 | + type: string |
| 111 | + description: What interface is used in the admin app to edit the value |
| 112 | + for this field. |
| 113 | + example: primary-key |
| 114 | + nullable: true |
| 115 | + options: |
| 116 | + type: object |
| 117 | + description: Options for the interface that's used. This format is |
| 118 | + based on the individual interface. |
| 119 | + example: |
| 120 | + nullable: true |
| 121 | + display: |
| 122 | + type: string |
| 123 | + description: What display is used in the admin app to display the |
| 124 | + value for this field. |
| 125 | + example: |
| 126 | + nullable: true |
| 127 | + display_options: |
| 128 | + type: object |
| 129 | + description: Options for the display that's used. This format is based |
| 130 | + on the individual display. |
| 131 | + example: |
| 132 | + nullable: true |
| 133 | + locked: |
| 134 | + type: boolean |
| 135 | + description: If the field can be altered by the end user. Directus |
| 136 | + system fields have this value set to `true`. |
| 137 | + example: true |
| 138 | + readonly: |
| 139 | + type: boolean |
| 140 | + description: Prevents the user from editing the value in the field. |
| 141 | + example: false |
| 142 | + required: |
| 143 | + type: boolean |
| 144 | + description: If this field should be required. |
| 145 | + example: false |
| 146 | + hidden: |
| 147 | + type: boolean |
| 148 | + description: If this field should be hidden. |
| 149 | + example: true |
| 150 | + sort: |
| 151 | + type: integer |
| 152 | + description: Sort order of this field on the edit page of the admin |
| 153 | + app. |
| 154 | + example: 1 |
| 155 | + nullable: true |
| 156 | + width: |
| 157 | + type: string |
| 158 | + description: Width of the field on the edit form. |
| 159 | + example: |
| 160 | + nullable: true |
| 161 | + enum: |
| 162 | + - half |
| 163 | + - half-left |
| 164 | + - half-right |
| 165 | + - full |
| 166 | + - fill |
| 167 | + - |
| 168 | + group: |
| 169 | + type: integer |
| 170 | + description: What field group this field is part of. |
| 171 | + example: |
| 172 | + nullable: true |
| 173 | + translation: |
| 174 | + type: object |
| 175 | + description: 'Key value pair of `<language>: <translation>` that allows |
| 176 | + the user to change the displayed name of the field in the admin |
| 177 | + app.' |
| 178 | + example: |
| 179 | + nullable: true |
| 180 | + note: |
| 181 | + type: string |
| 182 | + description: A user provided note for the field. Will be rendered |
| 183 | + alongside the interface on the edit page. |
| 184 | + example: '' |
| 185 | + nullable: true |
| 186 | +responses: |
| 187 | + '200': |
| 188 | + description: Successful request |
| 189 | + content: |
| 190 | + application/json: |
| 191 | + schema: |
| 192 | + type: object |
| 193 | + properties: |
| 194 | + data: |
| 195 | + type: array |
| 196 | + items: |
| 197 | + $ref: ../../../components/schemas/fields.yaml |
| 198 | + '401': |
| 199 | + $ref: ../../../components/responses.yaml#/UnauthorizedError |
| 200 | + '404': |
| 201 | + $ref: ../../../components/responses.yaml#/NotFoundError |
| 202 | +security: [] |
| 203 | +tags: |
| 204 | +- Fields |
| 205 | +parameters: |
| 206 | +- name: collection |
| 207 | + in: path |
| 208 | + description: Unique identifier of the collection the item resides in. |
| 209 | + schema: |
| 210 | + type: string |
| 211 | + required: true |
| 212 | +- $ref: ../../../components/parameters.yaml#/ConcurrentIndexCreation |
| 213 | +x-codeSamples: |
| 214 | + - label: Directus SDK |
| 215 | + lang: JavaScript |
| 216 | + source: | |
| 217 | + import { createDirectus, rest, updateFields } from '@directus/sdk'; |
| 218 | +
|
| 219 | + const client = createDirectus('directus_project_url').with(rest()); |
| 220 | +
|
| 221 | + const result = await client.request(updateFields(collection_name, partial_field_array)); |
| 222 | + - label: GraphQL |
| 223 | + lang: GraphQL |
| 224 | + source: | |
| 225 | + type Mutation { |
| 226 | + update_fields_item(collection: String!, data: update_directus_fields_input!): directus_fields |
| 227 | + } |
0 commit comments