loomio/loomio

View on GitHub
vue/src/shared/models/reaction_model.js

Summary

Maintainability
A
50 mins
Test Coverage
import BaseModel from '@/shared/record_store/base_model';
import AppConfig from '@/shared/services/app_config';

export default class ReactionModel extends BaseModel {
  static singular = 'reaction';
  static plural = 'reactions';
  static indices = ['userId', 'reactableId', 'reactableType'];

  relationships() {
    this.belongsTo('user');
  }

  model() {
    return this.recordStore[`${this.reactableType.toLowerCase()}s`].find(this.reactableId);
  }
};