controllers/userFavouriteController.js
/**
   * Replies with user favourite people.
   *
   * User data is retrieved from session and used to query favourite people for
   * the user.
   *
   * @param {fastify.Request} req Fastify request instance.
   * @param {fastify.Reply} rep Fastify reply instance.
   */
Replies with user favourite people.
User data is retrieved from session and used to query favourite people for
the user.

@param {fastify.Request} req Fastify request instance.
@param {fastify.Reply} rep Fastify reply instance.
Replies with user favourite people . User data is retrieved from session and used to query favourite people for the user . @param { fastify . Request } req Fastify request instance . @param { fastify . Reply } rep Fastify reply instance .
static async handleGetUserFavouritePeople(req, rep) {
    const userId = req.user.id;
    const personId = req.query.personId;
    const whereClause = {
      userId: userId
    };
    if(personId) {
      whereClause.personId = personId;
    }
    const favourites = await this.models.userCollectionsPersonFavourite.findAll({
      where: whereClause,
      include: [{
        model: this.models.collectionsPerson,
        as: 'person'
      }]
    });
    const serializedFavourites = FavouritePersonSerializer.serialize(favourites);
    await rep.send(serializedFavourites);
  }
static async handleGetUserFavouritePeople ( req , rep ) { const userId = req . user . id ; const personId = req . query . personId ; const whereClause = { userId : userId } ; if ( personId ) { whereClause . personId = personId ; } const favourites = await this . models . userCollectionsPersonFavourite . findAll ( { where : whereClause , include : [ { model : this . models . collectionsPerson , as : 'person' } ] } ) ; const serializedFavourites = FavouritePersonSerializer . serialize ( favourites ) ; await rep . send ( serializedFavourites ) ; }
Replies with user favourite people.
Replies with user favourite people .