* MM_30476 : Added all isolated tables from the server schema * MM_30476 : Updated 'test' script in package.json * MM_30476 : ADDED team section of the server schema * MM_30476 : Apply suggestions from code review Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * MM_30476 : Apply suggestions from code review Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * MM_30476 : Updates to field name and description Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Hossein <hahmadia@users.noreply.github.com> * MM_30476 : Updated my_team and team_search_history description * MM_30476 : Prefixing boolean fields with 'is' * MM_30476 : Updated channel.d.ts Co-authored-by: Hossein <hahmadia@users.noreply.github.com> Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * MM_30476 : ADDED lazy queries to TeamMembership Two methods that will retrieve all users in a team and all the teams that a user is part of * MM_30476 : Updated descriptions for the associations * MM_30476 : Updated tests as server schema was updated * MM_30476 : Updated Team to have a 1:1 relationship with TeamChannelHistory * MM_30476 : Updated team_membership and user Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Hossein <hahmadia@users.noreply.github.com>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 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, relation} from '@nozbe/watermelondb/decorators';
|
|
|
|
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 */
|
|
@field('roles') roles!: string;
|
|
|
|
/** team_id : The foreign key of the 'parent' Team entity */
|
|
@field('team_id') teamId!: string;
|
|
|
|
/** teams : The relation to the entity TEAM, that this user belongs to */
|
|
@relation(MY_TEAM, 'team_id') team!: Relation<Team>
|
|
}
|