Created
May 14, 2016 17:35
-
-
Save visualjeff/3d7d06be88d777153f61228d29c106d9 to your computer and use it in GitHub Desktop.
ember-data override to rev attributes when null. data source (couchdb) doesn't want a null rev attribute when adding (POSTing) a record.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Override is to accomidate couchdb and that it doesn't like like to see a revision or rev | |
//when creating a record. But because our model contains a rev (which is used for updates | |
//or patch request) we need to make sure during a POST request that we cut or remove the rev | |
//property out of the payload. Since Ember-Data sets it to null (record is about to be added) | |
//removing it won't hurt a thing. | |
serialize(snapshot, options) { | |
let data = this._super(...arguments); | |
if (data.data.attributes.rev === null) { | |
delete data.data.attributes.rev; | |
} | |
return data; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment