updateModel
The updateModel function updates an existing Entity model. It is the JavaScript/TypeScript counterpart of the PUT /model/entity/:id REST endpoint.
The params describe the desired final state of the model; the server reconciles them against the current model by field id. Keep the id of every field you want to preserve, add fields without an id, and omit a field to remove it (which also deletes its values from existing content).
Example:
// Rename the model, keep `title` (note its id), add a field; every omitted field is removed.const { id } = await client.updateModel(modelId, { name: 'BlogArticle', fieldList: [ { id: titleFieldId, name: 'title', type: 'short-text', validations: [{ name: 'required' }, { name: 'max-length', customArgs: { length: 200 } }] }, { name: 'readingMinutes', type: 'number' }, ],});Interface
export interface ApiClient { updateModel: (modelId: string, params: UpdateEntityParams) => Promise<SaveModelResponse>; // ... other methods}
// Same shape as CreateEntityParams — see createModel for FieldSpec / Validation.export type UpdateEntityParams = CreateEntityParams;
export interface SaveModelResponse { id: string;}Parameters
| Name | Description |
|---|---|
modelId | The id of the entity to update. |
params | The new name and the complete desired fieldList. See createModel for the FieldSpec shape, field types and validations. |
Output
Returns a Promise<SaveModelResponse> resolving to { id }. On failure it throws a typed
ApiClientError — NOT_FOUND if no entity has that id, VALIDATION_ERROR for a bad payload.