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

39 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} from '@nozbe/watermelondb/decorators';
import {MM_TABLES} from '@constants/database';
import Channel from '@typings/database/channel';
const {CHANNEL, POSTS_IN_CHANNEL} = MM_TABLES.SERVER;
/**
* PostsInChannel model helps us to combine adjacent posts together without leaving
* gaps in between for an efficient user reading experience of posts.
*/
export default class PostsInChannel extends Model {
/** table (entity name) : PostsInChannel */
static table = POSTS_IN_CHANNEL;
/** associations : Describes every relationship to this entity. */
static associations: Associations = {
/** A CHANNEL can have multiple POSTS_IN_CHANNEL. (relationship is 1:N)*/
[CHANNEL]: {type: 'belongs_to', key: 'channel_id'},
};
/** channel_id : The foreign key of the related parent channel */
@field('channel_id') channelId!: string;
/** earliest : The earliest timestamp of the post in that channel */
@field('earliest') earliest!: number;
/** latest : The latest timestamp of the post in that channel */
@field('latest') latest!: number;
/** channel : The parent record of the channel for those posts */
@immutableRelation(CHANNEL, 'channel_id') channel!: Relation<Channel>;
}