Files
mattermost-mobile/app/database/models/server/thread_participant.ts
Anurag Shivarathri 9dbdae22fd [Gekidou MM-39707] CRT DB (#5948)
* Database init

* Naming fix

* naming misc

* Fix test

* Added Thread Tab columns, Team Threads Count table and other changes

* Test case fix

* Test cases fix ...... AGAIN

* TS fix

* Removed loaded_in_all_threads_tab, loaded_in_unreads_tab

* Removed TeamThreadsCount table, mention & message root counts & added loadedInGlobalThreads flag

* Type changes, added delete thread with post

* Removed unused type

* Reverted relationshio of post with thread

* Calling thread destroyPermanently from post

* Removed unused table name variables

* added THREAD constant table in post model and fixed a few comments

* Misc typo fix and code clean up

* Added test case and related to participant in user model

* test cases fix

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2022-03-03 22:47:29 +05:30

44 lines
1.6 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Relation} from '@nozbe/watermelondb';
import {field, immutableRelation} from '@nozbe/watermelondb/decorators';
import Model, {Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import type ThreadModel from '@typings/database/models/servers/thread';
import type UserModel from '@typings/database/models/servers/user';
const {THREAD, THREAD_PARTICIPANT, USER} = MM_TABLES.SERVER;
/**
* The Thread Participants model contains participants data of a thread.
*/
export default class ThreadParticipantModel extends Model {
/** table (name) : ThreadParticipant */
static table = THREAD_PARTICIPANT;
/** associations : Describes every relationship to this table. */
static associations: Associations = {
/** A THREAD can have multiple PARTICIPANTS. (relationship is 1:N) */
[THREAD]: {type: 'belongs_to', key: 'thread_id'},
/** A USER can participate in multiple THREADS. (relationship is 1:N) */
[USER]: {type: 'belongs_to', key: 'user_id'},
};
/** thread_id : thread id to which participant belong to. */
@field('thread_id') threadId!: string;
/** user_id : user id of the participant. */
@field('user_id') userId!: number;
/** thread : The related record of the Thread model */
@immutableRelation(THREAD, 'thread_id') thread!: Relation<ThreadModel>;
/** user : The related record of the User model */
@immutableRelation(USER, 'user_id') user!: Relation<UserModel>;
}