0

I have a following schema

module.exports = (sequelize, DataTypes) => {
  const Photo = sequelize.define(
    "Photo",
    {
      photoURL: {
        type: DataTypes.STRING,
        allowNull: false
      },
      blurPhotoURL: {
        type: DataTypes.STRING,
        allowNull: false
      },
      userId: { //userId of user who has uploaded the photo
        type: DataTypes.UUID,
        allowNull: false
      },
      isPublic: {
        type: DataTypes.BOOLEAN,
        default: false
      }
    }
    {}
  );
}

I have one more schema SubscriberInfo

module.exports = (sequelize, DataTypes) => {
  const SubscriberInfo = sequelize.define(
    "SubscriberInfo",
    {
      userId: { // subscriber userId
        type: DataTypes.UUID,
        allowNull: false
      },
      modelId: { //subscribed userId
        type: DataTypes.UUID,
        allowNull: false
      }
    },
    {}
  );
}

So think like an Instagram profile where a user gets the ability to hide a photos and only his follower can see the photo and reset of the user will see blur version of the same photo.

I have managed to save blur photo and original photo in my db and isPublic is the column which tell if a photo is private or not.

On my UI(profile section) i want to display photos and blur photos depending on the user who is viewing the persons profile.

Can I achieve this in one query where in my returned JSON I get blurPhotoURL or photoURL depending who the user is and if the photo is isPublic or not.

Thank you in adv!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.