| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- const Schwifty = require('@hapipal/schwifty')
-
- const groupingSchema = require('../schemas/groupings')
- const Profile = require('./profile')
- const Tag = require('./tag')
-
- module.exports = class Grouping extends Schwifty.Model {
- static get tableName() {
- return 'groupings'
- }
- static get relationMappings() {
- return {
- profiles: {
- relation: Schwifty.Model.ManyToManyRelation,
- modelClass: Profile,
- join: {
- from: 'groupings.grouping_id',
- through: {
- from: 'memberships.grouping_id',
- to: 'memberships.profile_id',
- },
- to: 'profiles.profile_id',
- },
- },
- tags: {
- relation: Schwifty.Model.HasManyRelation,
- modelClass: Tag,
- join: {
- from: 'groupings.grouping_id',
- through: {
- from: 'tag_associations.grouping_id',
- to: 'tag_associations.tag_id',
- },
- to: 'tags.tag_id',
- },
- },
- }
- }
- static get joiSchema() {
- return groupingSchema.single
- }
- }
|