data icon indicating copy to clipboard operation
data copied to clipboard

Mistake in documentation of the serialize method

Open pbernery opened this issue 5 years ago • 1 comments

The documentation of serialize indicates that includeId is true when serializing for createRecord and not when updateRecord, which is true only when using the REST adapter:

// serializeIntoHash has the following signature and uses serialize behind:
function serializeIntoHash(store, modelClass, snapshot, options = { includeId: true })

// Creating
const data = serializeIntoHash(store, type, snapshot);
[...]
// Updating. Options are overridden and includeId is here considered `false`.
const data = serializeIntoHash(store, type, snapshot, {});

but not the JSON API one:

// Creating, same as REST
[...]
// Updating
const data = serializeIntoHash(store, type, snapshot);

I'd like to update the documentation with a PR, but I wonder what I should do:

  • remove the paragraph "The adapter passes in includeId: true when serializing a record for createRecord, but not for updateRecord."
  • mention how both REST and JSON API adapters behave.

pbernery avatar Sep 10 '20 12:09 pbernery

I think this is a situation where the documentation needs to be "copied forward". Each class should have it's own docs for all the methods even though some of them are shared and not re-implemented.

runspired avatar Apr 14 '21 08:04 runspired