mattermost-mobile/app/database/models/server/groups_in_team.ts
Avinash Lingaloo 78b76352c8
MM-30482 [Gekidou] Data Operator (#5346)
* MM_30482: Imported database and types /database folder

* MM_30482: Imported database and types /database folder

* MM_30482 : All tests are passing

* MM_30482 : Updating patch package for watermelon db

* MM_30482 : Fixing CI issue

* MM_30482 : Updating TS  complaint

* Update index.ts

* MM_30482 : Code clean up

Co-authored-by: Avinash Lingaloo <>
2021-04-22 19:16:00 +04:00

42 lines
1.5 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Relation} from '@nozbe/watermelondb';
import {field, immutableRelation} from '@nozbe/watermelondb/decorators';
import Model, {Associations} from '@nozbe/watermelondb/Model';
import Group from '@typings/database/group';
import {MM_TABLES} from '@constants/database';
import Team from '@typings/database/team';
const {GROUP, GROUPS_IN_TEAM, TEAM} = MM_TABLES.SERVER;
/**
* The GroupsInTeam links the Team model with the Group model
*/
export default class GroupsInTeam extends Model {
/** table (entity name) : GroupsInTeam */
static table = GROUPS_IN_TEAM;
/** associations : Describes every relationship to this entity. */
static associations: Associations = {
/** GroupsInTeam can belong to only one Group */
[GROUP]: {type: 'belongs_to', key: 'group_id'},
/** GroupsInTeam can belong to only one Team */
[TEAM]: {type: 'belongs_to', key: 'team_id'},
};
/** group_id : The foreign key to the related Group record */
@field('group_id') groupId!: string;
/** team_id : The foreign key to the related Team record */
@field('team_id') teamId!: string;
/** team : The related record to the parent Team model */
@immutableRelation(TEAM, 'team_id') team!: Relation<Team>;
/** group : The related record to the parent Team model */
@immutableRelation(GROUP, 'group_id') group!: Relation<Group>;
}