server/src/modules/thread/ThreadService.js
// this will be refactor into a scope
this will be refactor into a scope
this will be refactor into a scope
static async findOneByIdAndChannel(id, channelId) {
    const thread = await Thread.findOne({
      where: { id, channelId },
      include: [
        {
          model: Reply,
          as: 'replies',
          include: [
            {
              model: User,
              as: 'user',
            },
            {
              model: Favorite,
              as: 'favorites',
            },
          ],
        },
        {
          model: User,
          as: 'creator'
        },
        {
          model: Channel,
          as: 'channel'
        }
      ],
      order: [
        [{ model: Reply, as: 'replies' }, 'createdAt', 'DESC']
      ]
    });
    return thread;
  }
static async findOneByIdAndChannel ( id , channelId ) { const thread = await Thread . findOne ( { where : { id , channelId } , include : [ { model : Reply , as : 'replies' , include : [ { model : User , as : 'user' , } , { model : Favorite , as : 'favorites' , } , ] , } , { model : User , as : 'creator' } , { model : Channel , as : 'channel' } ] , order : [ [ { model : Reply , as : 'replies' } , 'createdAt' , 'DESC' ] ] } ) ; return thread ; }
this will be refactor into a scope
this will be refactor into a scope