Shopify/batman — Issue #289: Batman.Model#fromJSON & #toJSON aren't using @primaryKey
Author: tdegrunt
Created: 2011-12-21 19:55:46+00:00
State: open

Shouldn't Batman.Model#fromJSON at least use something similar as this:

obj['id'] = data[@constructor.primaryKey]

The Batman.Model#toJSON should likewise translate 'id' to the actual primaryKey, something similar to:

obj[@constructor.primaryKey] = obj.id
delete obj.id

This should ensure that, when talking to the backend the right @primaryKey is used.