generateIdForRecord (store, type, inputProperties) (String|Number)
If the globally unique IDs for your records should be generated on the client, implement the generateIdForRecord()
method. This method will be invoked each time you create a new record, and the value returned from it will be assigned to the record's primaryKey
.
Most traditional REST-like HTTP APIs will not use this method. Instead, the ID of the record will be set by the server, and your adapter will update the store with the new ID when it calls didCreateRecord()
. Only implement this method if you intend to generate record IDs on the client-side.
The generateIdForRecord()
method will be invoked with the requesting store as the first parameter and the newly created record as the second parameter:
import DS from 'ember-data'; import { v4 } from 'uuid'; export default DS.Adapter.extend({ generateIdForRecord: function(store, inputProperties) { return v4(); } });
Parameters:
Returns:
-
(String|Number)
- id
Please login to continue.