Build a Twitter Clone With Adonis and Vue

Tweet and Replies Relationship

A tweet can have multiple replies, while a single reply can only belongs to a particular tweet. This is a one-to-many relationship. Open app/Models/Tweet.js and add the code below to it:

// app/Models/Tweet.js

replies() {
    return this.hasMany('App/Models/Reply')
}

Then define the inverse relationship on the Reply model. Open app/Models/Reply.js and add the code below to it:

// app/Models/Reply.js

tweet() {
    return this.belongsTo('App/Models/Tweet')
}