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

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