{"size": 642, "ext": "js", "max_stars_repo_path": "src/queries/follows/followUser.js", "max_stars_repo_name": "luc-tuyishime/authors-haven-backend", "max_stars_repo_stars_event_min_datetime": "2019-04-23T21:20:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-06T23:47:23.000Z", "max_issues_repo_path": "src/queries/follows/followUser.js", "max_issues_repo_name": "luc-tuyishime/authors-haven-backend", "max_issues_repo_issues_event_min_datetime": "2019-04-24T16:34:14.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-08T20:18:19.000Z", "max_forks_repo_path": "src/queries/follows/followUser.js", "max_forks_repo_name": "luc-tuyishime/authors-haven-backend", "max_forks_repo_forks_event_min_datetime": "2019-04-23T11:46:11.000Z", "max_forks_repo_forks_event_max_datetime": "2021-09-07T17:48:56.000Z"}
{"max_stars_count": 12, "max_issues_count": 27, "max_forks_count": 9, "avg_line_length": 22.1379310345, "max_line_length": 85, "alphanum_fraction": 0.531152648}
import db from '../../models';

/**
 * @param {object} object
 * @returns {object} an object containing the information of the user or null
 */
export default async (object) => {
  try {
    const followUser = await db.Follows.create(
      { followed: object.followed, userId: object.userId },
      {
        logging: false,
        include: [
          {
            model: db.User,
            as: 'followedUser',
            attributes: ['id', 'firstName', 'lastName', 'username', 'email', 'image']
          }
        ]
      }
    );
    return followUser.dataValues;
  } catch (error) {
    return {
      errors: error
    };
  }
};
