mattermost-mobile/app/database/models/server/post_metadata.ts
Elias Nahum 324dbbd054
[Gekidou] fix database schema and models (#5553)
* fix database schema and models

* fix types
2021-07-20 23:24:42 +04:00

34 lines
1.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Relation} from '@nozbe/watermelondb';
import {immutableRelation, json} from '@nozbe/watermelondb/decorators';
import Model, {Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import {safeParseJSON} from '@utils/helpers';
import type PostModel from '@typings/database/models/servers/post';
const {POST, POST_METADATA} = MM_TABLES.SERVER;
/**
* PostMetadata provides additional information on a POST
*/
export default class PostMetadataModel extends Model {
/** table (name) : PostMetadata */
static table = POST_METADATA;
/** associations : Describes every relationship to this table. */
static associations: Associations = {
/** A POST can have multiple POST_METADATA.(relationship is 1:N)*/
[POST]: {type: 'belongs_to', key: 'id'},
};
/** data : Different types of data ranging from embeds to images. */
@json('data', safeParseJSON) data!: PostMetadata;
/** post: The record representing the POST parent. */
@immutableRelation(POST, 'id') post!: Relation<PostModel>;
}