Post.js 954 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Collection, Model } from 'js-abstract-model'
  2. import { CelebrityList } from 'src/models/Celebrity.js'
  3. import { PostCategory } from 'src/models/PostCategory.js'
  4. import { PostHashtagList } from 'src/models/PostHashtag.js'
  5. class Post extends Model {
  6. constructor (data) {
  7. super(data, [
  8. { key: 'id' },
  9. { key: 'title' },
  10. { key: 'text' },
  11. { key: 'summary' },
  12. { key: 'thumbnail' },
  13. { key: 'category' },
  14. { key: 'creation_time' },
  15. {
  16. key: 'category_info',
  17. relatedModel: PostCategory
  18. },
  19. {
  20. key: 'celebrities',
  21. relatedModel: CelebrityList
  22. },
  23. { key: 'hashtags' },
  24. {
  25. key: 'hashtags_info',
  26. relatedModel: PostHashtagList
  27. }
  28. ])
  29. if (!this.thumbnail) {
  30. this.thumbnail = '/img/sample-post-thumbnail.jpg'
  31. }
  32. }
  33. }
  34. class PostList extends Collection {
  35. model () {
  36. return Post
  37. }
  38. }
  39. export { Post, PostList }