forked from Ivasoft/mattermost-mobile
* Refactored storage layer - in progress * Refactored DatabaseManager & Operators * Renamed isRecordAppEqualToRaw to isRecordInfoEqualToRaw * Review feedback * Update app/database/models/app/info.ts Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * Update app/database/models/server/my_team.ts Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> Co-authored-by: Avinash Lingaloo <> Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
|
import {field, json} from '@nozbe/watermelondb/decorators';
|
|
|
|
import {MM_TABLES} from '@constants/database';
|
|
|
|
const {CHANNEL, DRAFT, POST} = MM_TABLES.SERVER;
|
|
|
|
/**
|
|
* The Draft model represents the draft state of messages in Direct/Group messages and in channels
|
|
*/
|
|
export default class Draft extends Model {
|
|
/** table (name) : Draft */
|
|
static table = DRAFT;
|
|
|
|
/** associations : Describes every relationship to this table. */
|
|
static associations: Associations = {
|
|
|
|
/** A DRAFT can belong to only one CHANNEL */
|
|
[CHANNEL]: {type: 'belongs_to', key: 'channel_id'},
|
|
|
|
/** A DRAFT is associated to only one POST */
|
|
[POST]: {type: 'belongs_to', key: 'root_id'},
|
|
};
|
|
|
|
/** channel_id : The foreign key pointing to the channel in which the draft was made */
|
|
@field('channel_id') channelId!: string;
|
|
|
|
/** message : The draft message */
|
|
@field('message') message!: string;
|
|
|
|
/** root_id : The root_id will be empty most of the time unless the draft relates to a draft reply of a thread */
|
|
@field('root_id') rootId!: string;
|
|
|
|
/** files : The files field will hold an array of file objects that have not yet been uploaded and persisted within the FILE table */
|
|
@json('files', (rawJson) => rawJson) files!: FileInfo[];
|
|
}
|