Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const Schwifty = require('@hapipal/schwifty')
  2. const Joi = require('joi')
  3. const TagAssociation = require('./tag-association')
  4. const Response = require('./response')
  5. const User = require('./user')
  6. module.exports = class Profile extends Schwifty.Model {
  7. static get tableName() {
  8. return 'profiles'
  9. }
  10. static get relationMappings() {
  11. return {
  12. tags: {
  13. relation: Schwifty.Model.HasManyRelation,
  14. modelClass: TagAssociation,
  15. join: {
  16. from: 'tag_associations.profile_id',
  17. to: 'profiles.profile_id',
  18. },
  19. },
  20. responses: {
  21. relation: Schwifty.Model.HasManyRelation,
  22. modelClass: Response,
  23. join: {
  24. from: 'responses.profile_id',
  25. to: 'profiles.profile_id',
  26. },
  27. },
  28. user: {
  29. relation: Schwifty.Model.BelongsToOneRelation,
  30. modelClass: User,
  31. join: {
  32. from: 'users.user_id',
  33. to: 'profiles.user_id',
  34. },
  35. },
  36. }
  37. }
  38. static get joiSchema() {
  39. return Joi.object({
  40. profile_id: Joi.number(),
  41. user_id: Joi.number(),
  42. })
  43. }
  44. }