Files
mattermost-mobile/app/database/models/server/posts_in_thread.ts
Avinash Lingaloo 9a72837f04 Gekidou - Updated Server Database Diagrams/Schema/Models (#6119)
* started with the diagrams

* removed redundant tables

next step:
1. reconstruct id ( local id vs server id )
2. annotate fields with examples
3. recreate relationship

* work in progress

* work in progress

* fix association

* update postsInChannel

* removed SlashCommands from the Server database schema

* added missing associations in the models and updated docs/database

* exported server database

* update test

* code corrections following review

* update relationship

* update docs

* removed cyclic relationship

* Revert "removed cyclic relationship"

This reverts commit 4d784efb81.

* removed isOptional from Draft

* linked myChannelSettings to myChannel instead of Channel

* update diagrams

* store null instead of empty string

* update thread association

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2022-04-07 10:14:28 -04:00

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 {field, immutableRelation} from '@nozbe/watermelondb/decorators';
import Model, {Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import type PostModel from '@typings/database/models/servers/post';
import type PostsInThreadModelInterface from '@typings/database/models/servers/posts_in_thread';
const {POST, POSTS_IN_THREAD} = MM_TABLES.SERVER;
/**
* PostsInThread model helps us to combine adjacent threads together without leaving
* gaps in between for an efficient user reading experience for threads.
*/
export default class PostsInThreadModel extends Model implements PostsInThreadModelInterface {
/** table (name) : PostsInThread */
static table = POSTS_IN_THREAD;
/** associations : Describes every relationship to this table. */
static associations: Associations = {
/** A POST can have multiple POSTS_IN_THREAD. (relationship is 1:N)*/
[POST]: {type: 'belongs_to', key: 'root_id'},
};
/** root_id: Associated root post identifier */
@field('root_id') rootId!: string;
/** earliest : Lower bound of a timestamp range */
@field('earliest') earliest!: number;
/** latest : Upper bound of a timestamp range */
@field('latest') latest!: number;
/** post : The related record to the parent Post model */
@immutableRelation(POST, 'root_id') post!: Relation<PostModel>;
}