@bakerac4 wrote:
A store can have many employees, and employees can have many stores. Model & Serializer for stores
export default DS.Model.extend({ name: DS.attr('string'), address: DS.attr('string'), address2: DS.attr('string'), city: DS.attr('string'), state: DS.attr('string'), zip: DS.attr('string'), employees: DS.hasMany('employee') }); export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, { isNewSerializerAPI: true, attrs: { employees: { serialize: 'records', deserialize: 'records' } } });
Model & Serializer for employee
export default DS.Model.extend({ firstName: DS.attr('string'), lastName: DS.attr('string'), stores: DS.hasMany('store'), name: Ember.computed('firstName', 'lastName', function() { return `${this.get('firstName')} ${this.get('lastName')}`; }) }); export default DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, { isNewSerializerAPI: true, attrs: { stores: { serialize: 'records', deserialize: 'records' } } });
When I try to save Im getting an uncaught range error. I just want to save the store with a full list of employees in one object.
But on another page I want to save an employee and a list of stores which is why its a hasMany relationship.
Posts: 1
Participants: 1