movieComment.ts 678 Bytes
import { Model } from "pinia-orm";
import { Movie } from "~/models/movie";

export class MovieComment extends Model {
  /**
   *
   * @return {string}
   */
  static get entity() {
    return "MovieComment";
  }

  /**
   *
   * @return {string}
   */
  static get primaryKey() {
    return "id";
  }

  static fields() {
    return {
      // Attributs.
      id: this.uid(),
      createdAt: this.string(""),
      username: this.string(""),
      message: this.string(""),
      rating: this.string(""),
      // Relations.
      movie_id: this.attr(null),
      movie: this.belongsTo(Movie, "movie_id", "id"),
    };
  }

  static piniaOptions = {
    persist: true,
  };
}