mattermost-mobile/app/database/models/server/my_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

41 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, relation} from '@nozbe/watermelondb/decorators';
import Model, {Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import Team from '@typings/database/team';
const {TEAM, MY_TEAM} = MM_TABLES.SERVER;
/**
* MyTeam represents only the teams that the current user belongs to
*/
export default class MyTeam extends Model {
/** table (entity name) : MyTeam */
static table = MY_TEAM;
/** associations : Describes every relationship to this entity. */
static associations: Associations = {
/** TEAM and MY_TEAM have a 1:1 relationship. */
[TEAM]: {type: 'belongs_to', key: 'team_id'},
};
/** is_unread : Boolean flag for unread messages on team level */
@field('is_unread') isUnread!: boolean;
/** mentions_count : Count of posts in which the user has been mentioned */
@field('mentions_count') mentionsCount!: number;
/** roles : The different permissions that this user has in the team, concatenated together with comma to form a single string. */
@field('roles') roles!: string;
/** team_id : The foreign key of the 'parent' Team entity */
@field('team_id') teamId!: string;
/** team : The relation to the entity TEAM, that this user belongs to */
@relation(MY_TEAM, 'team_id') team!: Relation<Team>;
}