# TrackChangesAdapter

interface

Track changes adapter.

The track changes adapter is an object that communicates asynchronously with the data source to fetch or save the suggestion data. It is used internally by the track changes feature whenever a suggestion is loaded, created or deleted.

The adapter is optional. You might need to provide it if you are [features/collaboration/track-changes/track-changes-integration](../features/collaboration/track-changes/track-changes-integration.md) using the track changes feature without real-time collaboration.

To set the adapter, overwrite [the `TrackChanges#adapter` property](module_track-changes_trackchanges-TrackChanges.md#member-adapter).

<a id="methods">

## Methods

<a id="function-addSuggestion">

### `addSuggestion( suggestionData ) → Promise<SuggestionData>`

Called each time a new suggestion is created.

The method should save the suggestion data in the database and return a promise that should be resolved when the save is completed.

If the promise resolves with an object with the `createdAt` property, this suggestion property will be updated in the suggestion in the editor. This lets you update the suggestion data with server-side information.

The `suggestionData` object does not expect the `authorId` property. For security reasons, the author of the suggestion should be set on the server side.

If `suggestionData.originalSuggestionId` is set, the new suggestion should have the `authorId` property set to the same as the suggestion with `originalSuggestionId`. This happens when one user splits another user's suggestion, creating a new suggestion as a result. See [Track changes integration](../features/collaboration/track-changes/track-changes-integration.md#implementation) guide.

**Note:** Failure to properly handle this property will result in editor crash in some scenarios.

In any other case, use the current (local) user to set `authorId`.

The `suggestionData` object does not expect the `createdAt` property either. You should use the server-side time generator to ensure that all users see the same date.

It is recommended to stringify `suggestionData.attributes` value to JSON and save it as a string in your database, and then to parse the strings when loading suggestions.

#### Parameters

* `suggestionData: AddSuggestionInput`

#### Returns

* `Promise<SuggestionData>`

<a id="function-getSuggestion">

### `getSuggestion( id ) → Promise<SuggestionData>`

Called each time the suggestion data is needed.

The method should return a promise that resolves with the suggestion data object.

#### Parameters

* `id: string`

  The ID of the suggestion to get.

#### Returns

* `Promise<SuggestionData>`

<a id="function-updateSuggestion">

### `updateSuggestion( id, suggestionData ) → Promise<void>`

Called each time the suggestion properties change.

The method should update the suggestion properties in the database and return a promise that should be resolved when the save is completed.

Keep in mind that the `data` parameter only contains those properties of a suggestion which changed.

#### Parameters

* `id: string`
* `suggestionData: UpdateSuggestionInput`

#### Returns

* `Promise<void>`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
