mattermost-mobile/app/database/models/server/groups_in_channel.ts
Elias Nahum 17e832e689
[Gekidou] Refactor storage layer (#5471)
* Refactored storage layer - in progress

* Refactored DatabaseManager & Operators

* Renamed isRecordAppEqualToRaw to isRecordInfoEqualToRaw

* Review feedback

* Update app/database/models/app/info.ts

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>

* Update app/database/models/server/my_team.ts

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>

Co-authored-by: Avinash Lingaloo <>
Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
2021-06-21 17:06:18 -04:00

48 lines
1.9 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Relation} from '@nozbe/watermelondb';
import Model, {Associations} from '@nozbe/watermelondb/Model';
import {field, immutableRelation} from '@nozbe/watermelondb/decorators';
import {MM_TABLES} from '@constants/database';
import Channel from '@typings/database/models/servers/channel';
import Group from '@typings/database/models/servers/group';
const {GROUP, GROUPS_IN_CHANNEL, CHANNEL} = MM_TABLES.SERVER;
/**
* The GroupsInChannel links the Channel model with the Group model
*/
export default class GroupsInChannel extends Model {
/** table (name) : GroupsInChannel */
static table = GROUPS_IN_CHANNEL;
/** associations : Describes every relationship to this table. */
static associations: Associations = {
/** A GROUP can be associated with multiple GROUPS_IN_CHANNEL (relationship is 1:N) */
[GROUP]: {type: 'belongs_to', key: 'group_id'},
/** A CHANNEL can be associated with multiple GROUPS_IN_CHANNEL (relationship is 1:N) */
[CHANNEL]: {type: 'belongs_to', key: 'channel_id'},
};
/** channel_id : The foreign key of the related CHANNEL model */
@field('channel_id') channelId!: string;
/** group_id : The foreign key of the related GROUP model */
@field('group_id') groupId!: string;
/** member_count : The number of members in that group */
@field('member_count') memberCount!: number;
/** timezone_count : The number of timezones in that group */
@field('timezone_count') timezoneCount!: number;
/** channel : The related record to the parent Channel model */
@immutableRelation(CHANNEL, 'channel_id') channel!: Relation<Channel>;
/** group : The related record to the parent Group model */
@immutableRelation(GROUP, 'group_id') group!: Relation<Group>;
}