FirebaseExtended/emberfire

Issue When Creating Record with hasMany Relationship

ChristopherJohnson25 opened this issue · 1 comments

DEBUG: -------------------------------
ember-console.js:43 DEBUG: Ember      : 3.0.0
ember-console.js:43 DEBUG: Ember Data : 3.4.4
ember-console.js:43 DEBUG: Firebase   : 3.9.0
ember-console.js:43 DEBUG: EmberFire  : 0.0.0
ember-console.js:43 DEBUG: jQuery     : 3.3.1

Expected behavior

I'd like to save my user-profile record normally without getting this error.

Actual behavior

Uncaught TypeError: serializer.hasDeserializeRecordsOption is not a function

I'm trying to create a record (user-profile) with a hasMany relationship but keep getting this error. At the time of saving, there is no record for the hasMany relationship as the user has not added them yet (no travel has been added at the time of create). For context, here are both models.

models/travel.js

import DS from 'ember-data';

export default DS.Model.extend({
  user: DS.hasMany("user-profile", { async: true }),
  title: DS.attr('string'),
  dateStart: DS.attr(),
  dateEnd: DS.attr(),
  components: DS.hasMany('trip-component', {async: true}),
  createdBy: DS.attr('string'),
  createdOn: DS.attr('string'),
  featuredImage: DS.attr('string'),
  featuredImageTitle: DS.attr('string')
});

models/user-profile.js

import DS from 'ember-data';

export default DS.Model.extend({
  firstName: DS.attr('string'),
  lastName: DS.attr('string'),
  email: DS.attr('string'),
  phoneNumber: DS.attr('string'),
  homeAirport: DS.attr(),
  city: DS.attr('string'),
  gender: DS.attr('string'),
  termsOfServiceAgree: DS.attr(),
  avatar: DS.attr('string'),
  favoriteTrips: DS.attr(),
  homeLat: DS.attr('string'),
  homeLng: DS.attr('string'),
  membershipLevel: DS.attr('string'),
  timesOnProfile: DS.attr('string'),
  travels: DS.hasMany('travel', {async: true})
});

What am I missing here?

Try to add the DS.EmbeddedRecordsMixin to your serializer even if you don't intend to use it.

The missing method is declared here