deleteModel
The deleteModel function deletes an Entity model and every content entry of that type. It is the JavaScript/TypeScript counterpart of the DELETE /model/entity/:id REST endpoint.
Example:
import { isApiClientError } from '@content-island/api-client';
try { await client.deleteModel(modelId); // resolves to `true` on success} catch (error) { if (isApiClientError(error) && error.code === 'CONFLICT') { // the model is referenced by a field on another model — repoint it first }}Interface
export interface ApiClient { deleteModel: (modelId: string) => Promise<boolean>; // ... other methods}Parameters
| Name | Description |
|---|---|
modelId | The id of the entity to delete. |
Output
Resolves to true when the model is deleted (HTTP 204). On failure it throws a typed
ApiClientError:
CONFLICT(409) — the model is referenced by arelationfield on another model. There is no force override; remove or repoint the referencing field first.NOT_FOUND(404) — no entity with that id exists.