ember-fryctoria icon indicating copy to clipboard operation
ember-fryctoria copied to clipboard

Ember Data transform is not not supported.

Open Chun-Yang opened this issue 9 years ago • 0 comments

Temporary work around:

Say you have a transform file like this: app/transforms/moment.js

/* global moment */
import Ember from 'ember';
import DS    from 'ember-data';
import ENV   from 'beauty-now-pro-ember/config/environment';

var format = ENV.APP.ISO_DATE_TIME_FORMAT;

export default DS.Transform.extend({
  deserialize: function(string) {
    var momentized = moment(string, format);
    return momentized;
  },

  serialize: function(momentized) {
    momentized.format(format);
  }
});

Since the record saved in jobs queue is a serialized json, you should replace serialize function with the following:

serialize: function(momentized) {
  if(momentized && momentized.format) {
    return momentized.format(format);
  } else {
    return momentized;
  }
}

Chun-Yang avatar Apr 10 '15 03:04 Chun-Yang