* 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>
42 lines
1.5 KiB
TypeScript
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 Model, {Associations} from '@nozbe/watermelondb/Model';
|
|
import {field, immutableRelation, text} from '@nozbe/watermelondb/decorators';
|
|
|
|
import {MM_TABLES} from '@constants/database';
|
|
import Team from '@typings/database/team';
|
|
|
|
const {TEAM, TEAM_SEARCH_HISTORY} = MM_TABLES.SERVER;
|
|
|
|
/**
|
|
* The TeamSearchHistory model holds the term searched within a team. The searches are performed
|
|
* at team level in the app.
|
|
*/
|
|
export default class TeamSearchHistory extends Model {
|
|
/** table (entity name) : TeamSearchHistory */
|
|
static table = TEAM_SEARCH_HISTORY;
|
|
|
|
/** associations : Describes every relationship to this entity. */
|
|
static associations: Associations = {
|
|
|
|
/** A TEAM can have multiple search terms */
|
|
[TEAM]: {type: 'belongs_to', key: 'team_id'},
|
|
};
|
|
|
|
/** createdAt : The timestamp at which this search was performed */
|
|
@field('created_at') createdAt!: number;
|
|
|
|
/** teamId : The foreign key to the parent Team model */
|
|
@field('team_id') teamId!: string;
|
|
|
|
/** displayTerm : The term that we display to the user */
|
|
@field('display_term') displayTerm!: string;
|
|
|
|
/** term : The term that is sent to the server to perform the search */
|
|
@text('term') term!: string;
|
|
|
|
/** team : The related record to the parent team model */
|
|
@immutableRelation(TEAM, 'team_id') team!: Relation<Team>;
|
|
}
|