Ember relationship problem

I need to save a user data onto my local storage . JSON.stringify an ember object, it is NOT saving relationships properly, Here I am getting the relationships out of the ember object and manually putting them in the JS plain object before saving it to the localStorage. This was working in ember-data 2.11 but it is throwing unknown mixin error related to relationship on ember-data 2.18. Please help

1 Like

If you share the code that is trying to take the ember data objects and put them into localStorage maybe I can see what’s going wrong.

Thank you for replying back, i have an extended object search.js inside model

// search.js
export default EmberObject.extend({
  days: Ember.computed('pickupDate', 'dropoffDate', function() {
    // - 1 second on the .diff() because
    // one day lasts for example from 10:00:00 to 9:59:59 but
    // our days last from 10:00:00 to 10:00:00
    return Math.ceil(moment.duration(getDateTimeObject(this.get('dropoffDate')).diff(getDateTimeObject(this.get('pickupDate'))) - 1).asDays());
  isCitySearch: Ember.computed('pickupDestination', function() {
    return !(new RegExp(/[A-Z]{3}/i).test(this.get('pickupDestination')));
  oneWayChanged: Ember.observer('isOneWay', function() {
    if (this.get('isOneWay') === false && this.get('is_deeplink') === false) {
      this.set('dropoffDestination', null);
    else if (this.get('isOneWay') === true && this.get('dropoffDestination') === null) {
      this.set('dropoffDestinationName', null);
    this.set('is_deeplink', false);
  pickupDestinationChanged: Ember.observer('pickupDestination', function() {
    if(this.get('isOneWay') !== true) {
      this.set('dropoffDestination', null);

This is the part of my service -

// user.js

const search = new Search({
      id: searchId,
      pos: this.get('config.MARKET'),
      products: [],
      stations: [],
      countries: [],
      pickupDestination: pickupDestination,
      dropoffDestination: dropoffDestination,
      search_uuid: searchId,
      user: this.get('user'),
      visit: this.get('user.visit')

here i create an object like this.

this is one of my model

// offer.js
export default DS.Model.extend({
  i18n: Ember.inject.service(),
  config: Ember.inject.service(),
  allCoverageTypes: Ember.computed.mapBy('relatedProducts', 'bundleLabelKey'),
  amountPayableAtPickupAmount: attr('number'),
  amountPayableAtPickupSupplierAmount: attr('number'),
  amountPayableNowAmount: attr('number'),
  amountPayableNowSupplierAmount: attr('number'),
  bundle: belongsTo('bundle', {async: false}),
  ipid_url: Ember.computed.readOnly('bundle.ipid_url'),
  search: DS.belongsTo('search', { async: false }),


These codes are working with ember-data 2.11 . But when i upgraded ember-data to 2.18 this is throwing unknown mixin error with relationship problem stated When i remove the code search: DS.belongsTo('search', { async: false }), the error wont appear and app loads. what went wrong on upgradation?

I’m not sure if it actually makes sense to have a belongsTo relationship to a thing that isn’t a DS.Model. Why can’t search be a plain javascript property?

Are you using something like EmbeddedRecordsMixin?

Thank you for your time. Yes, i am DS.EmbeddedRecordsMixin in serializer of offer.js . Is it unwanted ?