Files
mattermost-mobile/app/database/models/server/file.ts
Avinash Lingaloo 78b76352c8 MM-30482 [Gekidou] Data Operator (#5346)
* MM_30482: Imported database and types /database folder

* MM_30482: Imported database and types /database folder

* MM_30482 : All tests are passing

* MM_30482 : Updating patch package for watermelon db

* MM_30482 : Fixing CI issue

* MM_30482 : Updating TS  complaint

* Update index.ts

* MM_30482 : Code clean up

Co-authored-by: Avinash Lingaloo <>
2021-04-22 19:16:00 +04:00

57 lines
1.8 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 Post from '@typings/database/post';
const {FILE, POST} = MM_TABLES.SERVER;
/**
* The File model works in pair with the Post model. It hosts information about the files shared in a Post
*/
export default class File extends Model {
/** table (entity name) : File */
static table = FILE;
/** associations : Describes every relationship to this entity. */
static associations: Associations = {
/** A POST has a 1:N relationship with FILE. */
[POST]: {type: 'belongs_to', key: 'post_id'},
};
/** extension : The file's extension */
@field('extension') extension!: string;
/** height : The height for the image */
@field('height') height!: number;
/** image_thumbnail : A base64 representation of an image */
@field('image_thumbnail') imageThumbnail!: string;
/** local_path : Local path of the file that has been uploaded to server */
@field('local_path') localPath!: string;
/** mime_type : The media type */
@field('mime_type') mimeType!: string;
/** name : The name for the file object */
@field('name') name!: string;
/** post_id : The foreign key of the related Post model */
@field('post_id') postId!: string;
/** size : The numeric value of the size for the file */
@field('size') size!: number;
/** width : The width of the file object/image */
@field('width') width!: number;
/** post : The related Post record for this file */
@immutableRelation(POST, 'post_id') post!: Relation<Post>;
}