Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Need to ask about model relationship

$
0
0

@rzky wrote:

Hi, anyone mind taking a look at this model relationship? So i have an 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!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles