Need to ask about model relationship

Hi, anyone mind taking a look at this model relationship?

So i have a database of articles defined with a post and author model. Each article belongs to a single author, but will also support collaborative editing by multiple authors.

Is this the correct way to structure the model? (i’ve trimmed it down for clarity).

// models/post.js
export default DS.Model.extend({
  postid: DS.attr('string'),
  title: DS.attr('string'),
  text: DS.attr('string'),
  author: DS.belongsTo('author'),
  editors: DS.hasMany('author')
});

// models/author.js
export default DS.Model.extend({
  uid: DS.attr('string'),
  email: DS.attr('string'),
  posts: DS.hasMany('post'),
  // i feel something is missing here
});

I will be using ember + firebase if that’s any concern. Thx!

You can put a second hasMany on Author to relate back to the editor relationship. Use the inverse property on both posts and this other relationship to keep them straight.

@Chris_Lincoln like this?

// models/post.js
export default DS.Model.extend({
  postid: DS.attr('string'),
  title: DS.attr('string'),
  text: DS.attr('string'),
  author: DS.belongsTo('author'),
  editors: DS.hasMany('author', {inverse: 'edits'}) // update
});

// models/author.js
export default DS.Model.extend({
  uid: DS.attr('string'),
  email: DS.attr('string'),
  posts: DS.hasMany('post'),
  edits: DS.hasMany('post', {inverse: 'editors'}) // update
});

i’m honestly just making shit up. i don’t understand what the inverse property does.