Skip to content

Documentation / @ember-data/legacy-compat / builders / saveRecord

ts
function saveRecord<T>(record, options): SaveRecordRequestInput<TypeFromInstance<T>, T>;

Defined in: builders/save-record.ts:46

This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record). When passed to store.request, this config will result in the same behavior as a legacy store.saveRecord request. Additionally, it takes the same options as store.saveRecord.

All @ember-data/legacy-compat builders exist to enable you to migrate your codebase to using the correct syntax for store.request while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data.

Type Parameters

T

T extends TypedRecordInstance

Parameters

record

T

a record to save

options

Record<string, unknown> = {}

optional, may include adapterOptions hash which will be passed to adapter.saveRecord

Returns

SaveRecordRequestInput<TypeFromInstance<T>, T>

request config

Deprecated

Released under the MIT License.