mattermost-mobile/app/database/models/server/group_channel.ts
Elias Nahum 784b05fe97
Upgrade Dependencies (#7299)
* upgrade reanimated

* update devDependencies

* upgrade react-intl

* update react-native and some dependencies

* update react-native-permissions

* update RN

* use Share sheet for Report a problem

* update Sentry

* remove step to downloadWebRTC

* update detox deps

* feedback review
2023-04-21 12:16:54 -04:00

54 lines
2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {field, immutableRelation} from '@nozbe/watermelondb/decorators';
import Model, {type Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import type {Relation} from '@nozbe/watermelondb';
import type ChannelModel from '@typings/database/models/servers/channel';
import type GroupModel from '@typings/database/models/servers/group';
import type GroupChannelInterface from '@typings/database/models/servers/group_channel';
const {CHANNEL, GROUP, GROUP_CHANNEL} = MM_TABLES.SERVER;
/**
* The GroupChannel model represents the 'association table' where many groups have channels and many channels are in
* groups (relationship type N:N)
*/
export default class GroupChannelModel extends Model implements GroupChannelInterface {
/** table (name) : GroupChannel */
static table = GROUP_CHANNEL;
/** associations : Describes every relationship to this table. */
static associations: Associations = {
/** A GroupChannel belongs to a Group */
[GROUP]: {type: 'belongs_to', key: 'group_id'},
/** A GroupChannel has a Channel */
[CHANNEL]: {type: 'belongs_to', key: 'channel_id'},
};
/** group_id : The foreign key to the related Group record */
@field('group_id') groupId!: string;
/** channel_id : The foreign key to the related Channel record */
@field('channel_id') channelId!: string;
/** created_at : The creation date for this row */
@field('created_at') createdAt!: number;
/** updated_at : The update date for this row */
@field('updated_at') updatedAt!: number;
/** deleted_at : The delete date for this row */
@field('deleted_at') deletedAt!: number;
/** group : The related group */
@immutableRelation(GROUP, 'group_id') group!: Relation<GroupModel>;
/** channel : The related channel */
@immutableRelation(CHANNEL, 'channel_id') channel!: Relation<ChannelModel>;
}