dimanche 11 septembre 2016

emberfire embedded records throwing error

I have a firebase structure resembling the following:

{
  "individuals": {
    ...
    "7d29b6529277f3b2617a6eb0cb44ddb1": {
      "firstNames": "Tomas",
      "lastName": "Basham",
      "occupation": "Technical Director",
      "events": {
        "99a1404a443f7430cbb76d0659da9eb5": {
          "type": "birth",
          "date": "1990-10-26T00:00:00.000Z",
          "location": {
            "2dac207716378af1c4fae347f43bf500": true
          }
        }
      },
      "siblings": {
        "66e4a2b2e78fae73ef5aa35ea0f7e5c8": true
      }
    },
    ...
  },
  "locations": {
    ...
  }
}

Here the events object is supposed to be an embedded record within the individual.

I am trying to use emberfire to pull this data into my ember application. The models I have setup to do this are:

// app/models/event.js
import DS from 'ember-data';

const {
  attr,
  belongsTo
} = DS;

export default DS.Model.extend({
  type: attr('string'),
  date: attr('iso-date'),

  // Relationships
  location: belongsTo('location')
});

and

// app/models/individual.js
import DS from 'ember-data';

const {
  attr,
  hasMany
} = DS;

export default DS.Model.extend({
  firstNames: attr('string'),
  lastName: attr('string'),
  occupation: attr('string'),

  // Relationships
  events: hasMany('event', { async: false }), // embedded
  siblings: hasMany('individual', { inverse: null }),
  children: hasMany('individual', { inverse: null })
});

and

// app/models/location.js
import Ember from 'ember';
import DS from 'ember-data';

const {
  attr
} = DS;

export default DS.Model.extend({
  premise: attr('string'),
  sublocality: attr('string'),
  locality: attr('string'),
  administrativeArea2: attr('string'),
  administrativeArea1: attr('string'),
  country: attr('string'),
  coordinates: attr('raw', { defaultValue: [] })
});

Currently I am able to pull down all the individuals into the application, however the embedded records are not coming down with it. I also receive the following error: Error: Assertion Failed: Passing classes to store methods has been removed. Please pass a dasherized string instead of undefined.

I have setup a serializer too, as instructed, stating that the events keys in the individual model should be embedded. Does anybody have any idea what is going on?




Aucun commentaire:

Enregistrer un commentaire