mattermost-mobile/app/database/server/models/reaction.ts
Avinash Lingaloo 619503eedb
MM_30476 [v2] Section 'Channel' of the server schema (#5078)
* MM_30476 : Added all isolated tables from the server schema

* MM_30476 : Updated 'test' script in package.json

* MM_30476 : Rename table schemas to avoid name collision

* MM_30476 : Added 'Channel' section of the server schema

* MM_30476 : Apply suggestions from code review

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>

* MM_30476 : Converted @relation to @immutableRelation

* MM_30476 : Apply suggestions from code review

* MM_30476 : Apply suggestions from code review

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>

* MM_30476 : Minor updates to the comments

* MM_30476 : Minor update to the comments

* MM_30476 : Updated table schema exports

* MM_30476 : Updated comments

* MM_30476 : Apply suggestions from code review

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>

* MM_30476 : Update as per suggestions

* MM_30476 : Updated comments

* MM_30476 : Team and MyTeam share 1:1 relationship

* MM_30476 : Updated team comments

* MM_30476 : Updated myteam and team comments

Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2021-01-15 18:41:59 +04:00

48 lines
1.8 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} from '@nozbe/watermelondb/decorators';
import {MM_TABLES} from '@constants/database';
import User from '@typings/database/user';
import Post from '@typings/database/post';
const {POST, REACTION, USER} = MM_TABLES.SERVER;
/**
* The Reaction Model is used to present the reactions a user had on a particular post
*/
export default class Reaction extends Model {
/** table (entity name) : Reaction */
static table = REACTION;
/** associations : Describes every relationship to this entity. */
static associations: Associations = {
/** A POST can have multiple REACTION. (relationship is 1:N) */
[POST]: {type: 'belongs_to', key: 'post_id'},
/** A USER can have multiple REACTION. (relationship is 1:N) */
[USER]: {type: 'belongs_to', key: 'user_id'},
};
/** create_at : Creation timestamp used for sorting reactions amongst users on a particular post */
@field('create_at') createAt!: number;
/** emoji_name : The emoticon used to express the reaction */
@field('emoji_name') emojiName!: string;
/** post_id : The related Post's foreign key on which this reaction was expressed */
@field('post_id') postId!: string;
/** user_id : The related User's foreign key by which this reaction was expressed */
@field('user_id') userId!: string;
/** user : The related record to the User model */
@immutableRelation(USER, 'user_id') user!: Relation<User>;
/** post : The related record to the Post model */
@immutableRelation(POST, 'post_id') post!: Relation<Post>;
}