* 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 : ADDED section for Group from the server schema * MM_30476 : One PR for one section only * MM_30476 : One PR for one section only * MM_30476 : Rename table schemas to avoid name collision * MM_30476 : ADDED section 'Post' of the server schema * MM_30476 : Updated Post section of the server schema * MM_30476 : Apply suggestions from code review Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * MM_30476 : Corrected draft wrt to suggestions * MM_30476 : Apply suggestions from code review Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * MM_30476 : ADDED lazy queries to group_membership model * MM_30476 : Update model to match definition - GroupsInChannel * MM_30476 : Removed groups_in_team definition from Post section of this PR * MM_30476 : Updated all comments to match their variable/field name * MM_30476 : Updated test * MM_30476 : Updated imports and groups_in_team definition * MM_30476 : Updated FileInfo * MM_30476 : Updated Posts and PostMetadata ts types Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 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, json} from '@nozbe/watermelondb/decorators';
|
|
|
|
import {MM_TABLES} from '@constants/database';
|
|
import Post from '@typings/database/post';
|
|
|
|
const {POST, POST_METADATA} = MM_TABLES.SERVER;
|
|
|
|
/**
|
|
* PostMetadata provides additional information on a POST
|
|
*/
|
|
export default class PostMetadata extends Model {
|
|
/** table (entity name) : PostMetadata */
|
|
static table = POST_METADATA;
|
|
|
|
/** associations : Describes every relationship to this entity. */
|
|
static associations: Associations = {
|
|
|
|
/** A POST can have multiple POST_METADATA.(relationship is 1:N)*/
|
|
[POST]: {type: 'belongs_to', key: 'post_id'},
|
|
};
|
|
|
|
/** post_id : The foreign key of the parent POST model */
|
|
@field('post_id') postId!: string;
|
|
|
|
/** type : The type will work in tandem with the value present in the field 'data'. One 'type' for each kind of 'data' */
|
|
@field('type') type!: PostType;
|
|
|
|
/** data : Different types of data ranging from arrays, emojis, files to images and reactions. */
|
|
@json('data', (rawJson) => rawJson) data!: PostMetadataTypes;
|
|
|
|
/** post: The record representing the POST parent. */
|
|
@immutableRelation(POST, 'post_id') post!: Relation<Post>;
|
|
}
|