When working with a data store, you'll need to be able to handle relationships. In this recipe, we'll go over some common relationships from one-to-many and many-to-one and also how to use it with Ember Data.
As with the other recipes, we'll be using Ember CLI Mirage to mock our backend. In this recipe, we'll create a simple one-to-many and many-to-one relationship. We'll mock a school that has instructors and classes. For every class, there is one instructor. Every instructor will have one or more classes.
Create a new Ember application. In this application, generate the following files:
$ ember install ember-cli-mirage $ ember g model instructor $ ember g model class $ ember g route index $ ember g helper addone $ ember g adapter application $ ember g fixture classes $ ember g fixture instructors
This will create the models, route, adapter, and helper that we'll need for this application.
In the
mirage
fixtures
folder, update these two files,classes...