Function

name
String
the name of the relationship
store
Store
returns
Object
the inverse relationship, or null

Find the relationship which is the inverse of the one asked for.

For example, if you define models like this:

app/models/post.js
1
2
3
4
5
import Model, { hasMany } from '@ember-data/model';

export default class PostModel extends Model {
   @hasMany('message') comments;
 }
app/models/message.js
1
2
3
4
5
import Model, { belongsTo } from '@ember-data/model';

export default class MessageModel extends Model {
   @belongsTo('post') owner;
 }
1
2
store.modelFor('post').inverseFor('comments', store) // { type: App.Message, name: 'owner', kind: 'belongsTo' }
store.modelFor('message').inverseFor('owner', store) // { type: App.Post, name: 'comments', kind: 'hasMany' }