forked from Ivasoft/mattermost-mobile
Gekidou - Fix to make all models implement their respective interface (#6099)
* make all models implement their respective interface * make all models implement their respective interface
This commit is contained in:
@@ -7,6 +7,8 @@ import {json} from '@nozbe/watermelondb/decorators';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {safeParseJSON} from '@utils/helpers';
|
||||
|
||||
import type GlobalModelInterface from '@typings/database/models/app/global';
|
||||
|
||||
const {GLOBAL} = MM_TABLES.APP;
|
||||
|
||||
// TODO : add TS definitions to sanitizer function signature.
|
||||
@@ -15,7 +17,7 @@ const {GLOBAL} = MM_TABLES.APP;
|
||||
* The Global model will act as a dictionary of name-value pairs. The value field can be a JSON object or any other
|
||||
* data type. It will hold information that applies to the whole app ( e.g. sidebar settings for tablets)
|
||||
*/
|
||||
export default class GlobalModel extends Model {
|
||||
export default class GlobalModel extends Model implements GlobalModelInterface {
|
||||
/** table (name) : global */
|
||||
static table = GLOBAL;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {Model} from '@nozbe/watermelondb';
|
||||
import {field} from '@nozbe/watermelondb/decorators';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import InfoModelInterface from '@typings/database/models/app/info';
|
||||
|
||||
const {INFO} = MM_TABLES.APP;
|
||||
|
||||
@@ -12,7 +13,7 @@ const {INFO} = MM_TABLES.APP;
|
||||
* The App model will hold information - such as the version number, build number and creation date -
|
||||
* for the Mattermost mobile app.
|
||||
*/
|
||||
export default class InfoModel extends Model {
|
||||
export default class InfoModel extends Model implements InfoModelInterface {
|
||||
/** table (name) : info */
|
||||
static table = INFO;
|
||||
|
||||
|
||||
@@ -6,13 +6,15 @@ import {field} from '@nozbe/watermelondb/decorators';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type ServersModelInterface from '@typings/database/models/app/servers';
|
||||
|
||||
const {SERVERS} = MM_TABLES.APP;
|
||||
|
||||
/**
|
||||
* The Server model will help us to identify the various servers a user will log in; in the context of
|
||||
* multi-server support system. The db_path field will hold the App-Groups file-path
|
||||
*/
|
||||
export default class ServersModel extends Model {
|
||||
export default class ServersModel extends Model implements ServersModelInterface {
|
||||
/** table (name) : servers */
|
||||
static table = SERVERS;
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {Relation} from '@nozbe/watermelondb';
|
||||
import {Query, Relation} from '@nozbe/watermelondb';
|
||||
import {children, field, immutableRelation} from '@nozbe/watermelondb/decorators';
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type CategoryChannelModel from '@typings/database/models/servers/category_channel';
|
||||
import type ChannelModelInterface from '@typings/database/models/servers/channel';
|
||||
import type ChannelInfoModel from '@typings/database/models/servers/channel_info';
|
||||
import type ChannelMembershipModel from '@typings/database/models/servers/channel_membership';
|
||||
import type DraftModel from '@typings/database/models/servers/draft';
|
||||
@@ -35,7 +36,7 @@ const {
|
||||
/**
|
||||
* The Channel model represents a channel in the Mattermost app.
|
||||
*/
|
||||
export default class ChannelModel extends Model {
|
||||
export default class ChannelModel extends Model implements ChannelModelInterface {
|
||||
/** table (name) : Channel */
|
||||
static table = CHANNEL;
|
||||
|
||||
@@ -101,16 +102,16 @@ export default class ChannelModel extends Model {
|
||||
@field('type') type!: ChannelType;
|
||||
|
||||
/** members : Users belonging to this channel */
|
||||
@children(CHANNEL_MEMBERSHIP) members!: ChannelMembershipModel[];
|
||||
@children(CHANNEL_MEMBERSHIP) members!: Query<ChannelMembershipModel>;
|
||||
|
||||
/** drafts : All drafts for this channel */
|
||||
@children(DRAFT) drafts!: DraftModel[];
|
||||
@children(DRAFT) drafts!: Query<DraftModel>;
|
||||
|
||||
/** posts : All posts made in that channel */
|
||||
@children(POST) posts!: PostModel[];
|
||||
@children(POST) posts!: Query<PostModel>;
|
||||
|
||||
/** postsInChannel : a section of the posts for that channel bounded by a range */
|
||||
@children(POSTS_IN_CHANNEL) postsInChannel!: PostsInChannelModel[];
|
||||
@children(POSTS_IN_CHANNEL) postsInChannel!: Query<PostsInChannelModel>;
|
||||
|
||||
/** team : The TEAM to which this CHANNEL belongs */
|
||||
@immutableRelation(TEAM, 'team_id') team!: Relation<TeamModel>;
|
||||
|
||||
@@ -8,6 +8,7 @@ import Model from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type ChannelModel from '@typings/database/models/servers/channel';
|
||||
import type ChannelInfoInterface from '@typings/database/models/servers/channel_info';
|
||||
|
||||
const {CHANNEL, CHANNEL_INFO} = MM_TABLES.SERVER;
|
||||
|
||||
@@ -16,7 +17,7 @@ const {CHANNEL, CHANNEL_INFO} = MM_TABLES.SERVER;
|
||||
* In a Separation of Concerns approach, ChannelInfo will provide additional information about a channel but on a more
|
||||
* specific level.
|
||||
*/
|
||||
export default class ChannelInfoModel extends Model {
|
||||
export default class ChannelInfoModel extends Model implements ChannelInfoInterface {
|
||||
/** table (name) : ChannelInfo */
|
||||
static table = CHANNEL_INFO;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type ChannelModel from '@typings/database/models/servers/channel';
|
||||
import type ChannelMembershipModelInterface from '@typings/database/models/servers/channel_membership';
|
||||
import type UserModel from '@typings/database/models/servers/user';
|
||||
|
||||
const {CHANNEL, CHANNEL_MEMBERSHIP, USER} = MM_TABLES.SERVER;
|
||||
@@ -16,7 +17,7 @@ const {CHANNEL, CHANNEL_MEMBERSHIP, USER} = MM_TABLES.SERVER;
|
||||
* The ChannelMembership model represents the 'association table' where many channels have users and many users are on
|
||||
* channels ( N:N relationship between model Users and model Channel)
|
||||
*/
|
||||
export default class ChannelMembershipModel extends Model {
|
||||
export default class ChannelMembershipModel extends Model implements ChannelMembershipModelInterface {
|
||||
/** table (name) : ChannelMembership */
|
||||
static table = CHANNEL_MEMBERSHIP;
|
||||
|
||||
|
||||
@@ -6,10 +6,12 @@ import {field} from '@nozbe/watermelondb/decorators';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type CustomEmojiModelInterface from '@typings/database/models/servers/custom_emoji';
|
||||
|
||||
const {CUSTOM_EMOJI} = MM_TABLES.SERVER;
|
||||
|
||||
/** The CustomEmoji model describes all the custom emojis used in the Mattermost app */
|
||||
export default class CustomEmojiModel extends Model {
|
||||
export default class CustomEmojiModel extends Model implements CustomEmojiModelInterface {
|
||||
/** table (name) : CustomEmoji */
|
||||
static table = CUSTOM_EMOJI;
|
||||
|
||||
|
||||
@@ -7,12 +7,14 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {safeParseJSON} from '@utils/helpers';
|
||||
|
||||
import type DraftModelInterface from '@typings/database/models/servers/draft';
|
||||
|
||||
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 DraftModel extends Model {
|
||||
export default class DraftModel extends Model implements DraftModelInterface {
|
||||
/** table (name) : Draft */
|
||||
static table = DRAFT;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type FileModelInterface from '@typings/database/models/servers/file';
|
||||
import type PostModel from '@typings/database/models/servers/post';
|
||||
|
||||
const {FILE, POST} = MM_TABLES.SERVER;
|
||||
@@ -14,7 +15,7 @@ const {FILE, POST} = MM_TABLES.SERVER;
|
||||
/**
|
||||
* The File model works in pair with the Post model. It hosts information about the files attached to a Post
|
||||
*/
|
||||
export default class FileModel extends Model {
|
||||
export default class FileModel extends Model implements FileModelInterface {
|
||||
/** table (name) : File */
|
||||
static table = FILE;
|
||||
|
||||
|
||||
@@ -8,13 +8,14 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type ChannelModel from '@typings/database/models/servers/channel';
|
||||
import type MyChannelModelInterface from '@typings/database/models/servers/my_channel';
|
||||
|
||||
const {CATEGORY_CHANNEL, CHANNEL, MY_CHANNEL} = MM_TABLES.SERVER;
|
||||
|
||||
/**
|
||||
* MyChannel is an extension of the Channel model but it lists only the Channels the app's user belongs to
|
||||
*/
|
||||
export default class MyChannelModel extends Model {
|
||||
export default class MyChannelModel extends Model implements MyChannelModelInterface {
|
||||
/** table (name) : MyChannel */
|
||||
static table = MY_CHANNEL;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {MM_TABLES} from '@constants/database';
|
||||
import {safeParseJSON} from '@utils/helpers';
|
||||
|
||||
import type ChannelModel from '@typings/database/models/servers/channel';
|
||||
import type MyChannelSettingsModelInterface from '@typings/database/models/servers/my_channel_settings';
|
||||
|
||||
const {CHANNEL, MY_CHANNEL_SETTINGS} = MM_TABLES.SERVER;
|
||||
|
||||
@@ -16,11 +17,11 @@ const {CHANNEL, MY_CHANNEL_SETTINGS} = MM_TABLES.SERVER;
|
||||
* The MyChannelSettings model represents the specific user's configuration to
|
||||
* the channel this user belongs to.
|
||||
*/
|
||||
export default class MyChannelSettingsModel extends Model {
|
||||
export default class MyChannelSettingsModel extends Model implements MyChannelSettingsModelInterface {
|
||||
/** table (name) : MyChannelSettings */
|
||||
static table = MY_CHANNEL_SETTINGS;
|
||||
|
||||
/** notify_props : Configurations with regards to this channel */
|
||||
/** notify_props : Configurations in regard to this channel */
|
||||
@json('notify_props', safeParseJSON) notifyProps!: ChannelNotifyProps;
|
||||
|
||||
/** channel : The relation pointing to the CHANNEL table */
|
||||
|
||||
@@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type MyTeamModelInterface from '@typings/database/models/servers/my_team';
|
||||
import type TeamModel from '@typings/database/models/servers/team';
|
||||
|
||||
const {TEAM, MY_TEAM} = MM_TABLES.SERVER;
|
||||
@@ -14,7 +15,7 @@ const {TEAM, MY_TEAM} = MM_TABLES.SERVER;
|
||||
/**
|
||||
* MyTeam represents only the teams that the current user belongs to
|
||||
*/
|
||||
export default class MyTeamModel extends Model {
|
||||
export default class MyTeamModel extends Model implements MyTeamModelInterface {
|
||||
/** table (name) : MyTeam */
|
||||
static table = MY_TEAM;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import {safeParseJSON} from '@utils/helpers';
|
||||
import type ChannelModel from '@typings/database/models/servers/channel';
|
||||
import type DraftModel from '@typings/database/models/servers/draft';
|
||||
import type FileModel from '@typings/database/models/servers/file';
|
||||
import type PostModelInterface from '@typings/database/models/servers/post';
|
||||
import type PostInThreadModel from '@typings/database/models/servers/posts_in_thread';
|
||||
import type ReactionModel from '@typings/database/models/servers/reaction';
|
||||
import type ThreadModel from '@typings/database/models/servers/thread';
|
||||
@@ -21,7 +22,7 @@ const {CHANNEL, DRAFT, FILE, POST, POSTS_IN_THREAD, REACTION, THREAD, USER} = MM
|
||||
/**
|
||||
* The Post model is the building block of communication in the Mattermost app.
|
||||
*/
|
||||
export default class PostModel extends Model {
|
||||
export default class PostModel extends Model implements PostModelInterface {
|
||||
/** table (name) : Post */
|
||||
static table = POST;
|
||||
|
||||
@@ -96,7 +97,7 @@ export default class PostModel extends Model {
|
||||
@json('props', safeParseJSON) props!: any;
|
||||
|
||||
// A draft can be associated with this post for as long as this post is a parent post
|
||||
@lazy draft = this.collections.get(DRAFT).query(Q.on(POST, 'id', this.id)) as Query<DraftModel>;
|
||||
@lazy drafts = this.collections.get(DRAFT).query(Q.on(POST, 'id', this.id)) as Query<DraftModel>;
|
||||
|
||||
@lazy root = this.collection.query(Q.where('id', this.rootId)) as Query<PostModel>;
|
||||
|
||||
@@ -125,7 +126,7 @@ export default class PostModel extends Model {
|
||||
async destroyPermanently() {
|
||||
await this.reactions.destroyAllPermanently();
|
||||
await this.files.destroyAllPermanently();
|
||||
await this.draft.destroyAllPermanently();
|
||||
await this.drafts.destroyAllPermanently();
|
||||
await this.collections.get(POSTS_IN_THREAD).query(
|
||||
Q.where('root_id', this.id),
|
||||
).destroyAllPermanently();
|
||||
|
||||
@@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type ChannelModel from '@typings/database/models/servers/channel';
|
||||
import type PostsInChannelModelInterface from '@typings/database/models/servers/posts_in_channel';
|
||||
|
||||
const {CHANNEL, POSTS_IN_CHANNEL} = MM_TABLES.SERVER;
|
||||
|
||||
@@ -15,7 +16,7 @@ const {CHANNEL, POSTS_IN_CHANNEL} = MM_TABLES.SERVER;
|
||||
* PostsInChannel model helps us to combine adjacent posts together without leaving
|
||||
* gaps in between for an efficient user reading experience of posts.
|
||||
*/
|
||||
export default class PostsInChannelModel extends Model {
|
||||
export default class PostsInChannelModel extends Model implements PostsInChannelModelInterface {
|
||||
/** table (name) : PostsInChannel */
|
||||
static table = POSTS_IN_CHANNEL;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
|
||||
@@ -15,7 +16,7 @@ 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 {
|
||||
export default class PostsInThreadModel extends Model implements PostsInThreadModelInterface {
|
||||
/** table (name) : PostsInThread */
|
||||
static table = POSTS_IN_THREAD;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type PreferenceModelInterface from '@typings/database/models/servers/preference';
|
||||
import type UserModel from '@typings/database/models/servers/user';
|
||||
|
||||
const {PREFERENCE, USER} = MM_TABLES.SERVER;
|
||||
@@ -15,7 +16,7 @@ const {PREFERENCE, USER} = MM_TABLES.SERVER;
|
||||
* The Preference model hold information about the user's preference in the app.
|
||||
* This includes settings about the account, the themes, etc.
|
||||
*/
|
||||
export default class PreferenceModel extends Model {
|
||||
export default class PreferenceModel extends Model implements PreferenceModelInterface {
|
||||
/** table (name) : Preference */
|
||||
static table = PREFERENCE;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type PostModel from '@typings/database/models/servers/post';
|
||||
import type ReactionModelInterface from '@typings/database/models/servers/reaction';
|
||||
import type UserModel from '@typings/database/models/servers/user';
|
||||
|
||||
const {POST, REACTION, USER} = MM_TABLES.SERVER;
|
||||
@@ -15,7 +16,7 @@ const {POST, REACTION, USER} = MM_TABLES.SERVER;
|
||||
/**
|
||||
* The Reaction Model is used to present the reactions a user had on a particular post
|
||||
*/
|
||||
export default class ReactionModel extends Model {
|
||||
export default class ReactionModel extends Model implements ReactionModelInterface {
|
||||
/** table (name) : Reaction */
|
||||
static table = REACTION;
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@ import {field, json} from '@nozbe/watermelondb/decorators';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {safeParseJSON} from '@utils/helpers';
|
||||
|
||||
import type RoleModelInterface from '@typings/database/models/servers/role';
|
||||
|
||||
const {ROLE} = MM_TABLES.SERVER;
|
||||
|
||||
/** The Role model will describe the set of permissions for each role */
|
||||
export default class RoleModel extends Model {
|
||||
export default class RoleModel extends Model implements RoleModelInterface {
|
||||
/** table (name) : Role */
|
||||
static table = ROLE;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type SlashCommandModelInterface from '@typings/database/models/servers/slash_command';
|
||||
import type TeamModel from '@typings/database/models/servers/team';
|
||||
|
||||
const {SLASH_COMMAND, TEAM} = MM_TABLES.SERVER;
|
||||
@@ -14,7 +15,7 @@ const {SLASH_COMMAND, TEAM} = MM_TABLES.SERVER;
|
||||
/**
|
||||
* The SlashCommand model describes the commands of the various commands available in each team.
|
||||
*/
|
||||
export default class SlashCommandModel extends Model {
|
||||
export default class SlashCommandModel extends Model implements SlashCommandModelInterface {
|
||||
/** table (name) : SlashCommand */
|
||||
static table = SLASH_COMMAND;
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import {json} from '@nozbe/watermelondb/decorators';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {safeParseJSON} from '@utils/helpers';
|
||||
|
||||
import type SystemModelInterface from '@typings/database/models/servers/system';
|
||||
|
||||
const {SYSTEM} = MM_TABLES.SERVER;
|
||||
|
||||
/**
|
||||
@@ -14,7 +16,7 @@ const {SYSTEM} = MM_TABLES.SERVER;
|
||||
* will mostly hold configuration information about the client, the licences and some
|
||||
* custom data (e.g. recent emoji used)
|
||||
*/
|
||||
export default class SystemModel extends Model {
|
||||
export default class SystemModel extends Model implements SystemModelInterface {
|
||||
/** table (name) : System */
|
||||
static table = SYSTEM;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {Q, Relation} from '@nozbe/watermelondb';
|
||||
import {Q, Query, Relation} from '@nozbe/watermelondb';
|
||||
import {children, field, immutableRelation, lazy} from '@nozbe/watermelondb/decorators';
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
@@ -11,6 +11,7 @@ import type CategoryModel from '@typings/database/models/servers/category';
|
||||
import type ChannelModel from '@typings/database/models/servers/channel';
|
||||
import type MyTeamModel from '@typings/database/models/servers/my_team';
|
||||
import type SlashCommandModel from '@typings/database/models/servers/slash_command';
|
||||
import type TeamModelInterface from '@typings/database/models/servers/team';
|
||||
import type TeamChannelHistoryModel from '@typings/database/models/servers/team_channel_history';
|
||||
import type TeamMembershipModel from '@typings/database/models/servers/team_membership';
|
||||
import type TeamSearchHistoryModel from '@typings/database/models/servers/team_search_history';
|
||||
@@ -32,7 +33,7 @@ const {
|
||||
/**
|
||||
* A Team houses and enables communication to happen across channels and users.
|
||||
*/
|
||||
export default class TeamModel extends Model {
|
||||
export default class TeamModel extends Model implements TeamModelInterface {
|
||||
/** table (name) : Team */
|
||||
static table = TEAM;
|
||||
|
||||
@@ -89,25 +90,25 @@ export default class TeamModel extends Model {
|
||||
@field('allowed_domains') allowedDomains!: string;
|
||||
|
||||
/** categories : All the categories associated with this team */
|
||||
@children(CATEGORY) categories!: CategoryModel[];
|
||||
@children(CATEGORY) categories!: Query<CategoryModel>;
|
||||
|
||||
/** channels : All the channels associated with this team */
|
||||
@children(CHANNEL) channels!: ChannelModel[];
|
||||
@children(CHANNEL) channels!: Query<ChannelModel>;
|
||||
|
||||
/** myTeam : Retrieves additional information about the team that this user is possibly part of. */
|
||||
@immutableRelation(MY_TEAM, 'id') myTeam!: Relation<MyTeamModel>;
|
||||
|
||||
/** slashCommands : All the slash commands associated with this team */
|
||||
@children(SLASH_COMMAND) slashCommands!: SlashCommandModel[];
|
||||
@children(SLASH_COMMAND) slashCommands!: Query<SlashCommandModel>;
|
||||
|
||||
/** teamChannelHistory : A history of the channels in this team that has been visited, ordered by the most recent and capped to the last 5 */
|
||||
@immutableRelation(TEAM_CHANNEL_HISTORY, 'id') teamChannelHistory!: Relation<TeamChannelHistoryModel>;
|
||||
|
||||
/** members : All the users associated with this team */
|
||||
@children(TEAM_MEMBERSHIP) members!: TeamMembershipModel[];
|
||||
@children(TEAM_MEMBERSHIP) members!: Query<TeamMembershipModel>;
|
||||
|
||||
/** teamSearchHistories : All the searches performed on this team */
|
||||
@children(TEAM_SEARCH_HISTORY) teamSearchHistories!: TeamSearchHistoryModel[];
|
||||
@children(TEAM_SEARCH_HISTORY) teamSearchHistories!: Query<TeamSearchHistoryModel>;
|
||||
|
||||
/** threads : All threads belonging to a team */
|
||||
@lazy threads = this.collections.get<ThreadModel>(THREAD).query(
|
||||
|
||||
@@ -9,6 +9,7 @@ import {MM_TABLES} from '@constants/database';
|
||||
import {safeParseJSON} from '@utils/helpers';
|
||||
|
||||
import type TeamModel from '@typings/database/models/servers/team';
|
||||
import type TeamChannelHistoryModelInterface from '@typings/database/models/servers/team_channel_history';
|
||||
|
||||
const {TEAM, TEAM_CHANNEL_HISTORY} = MM_TABLES.SERVER;
|
||||
|
||||
@@ -16,7 +17,7 @@ const {TEAM, TEAM_CHANNEL_HISTORY} = MM_TABLES.SERVER;
|
||||
* The TeamChannelHistory model helps keeping track of the last channel visited
|
||||
* by the user.
|
||||
*/
|
||||
export default class TeamChannelHistoryModel extends Model {
|
||||
export default class TeamChannelHistoryModel extends Model implements TeamChannelHistoryModelInterface {
|
||||
/** table (name) : TeamChannelHistory */
|
||||
static table = TEAM_CHANNEL_HISTORY;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type TeamModel from '@typings/database/models/servers/team';
|
||||
import type TeamMembershipModelInterface from '@typings/database/models/servers/team_membership';
|
||||
import type UserModel from '@typings/database/models/servers/user';
|
||||
|
||||
const {TEAM, TEAM_MEMBERSHIP, USER} = MM_TABLES.SERVER;
|
||||
@@ -16,7 +17,7 @@ const {TEAM, TEAM_MEMBERSHIP, USER} = MM_TABLES.SERVER;
|
||||
* The TeamMembership model represents the 'association table' where many teams have users and many users are in
|
||||
* teams (relationship type N:N)
|
||||
*/
|
||||
export default class TeamMembershipModel extends Model {
|
||||
export default class TeamMembershipModel extends Model implements TeamMembershipModelInterface {
|
||||
/** table (name) : TeamMembership */
|
||||
static table = TEAM_MEMBERSHIP;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type TeamModel from '@typings/database/models/servers/team';
|
||||
import type TeamSearchHistoryModelInterface from '@typings/database/models/servers/team_search_history';
|
||||
|
||||
const {TEAM, TEAM_SEARCH_HISTORY} = MM_TABLES.SERVER;
|
||||
|
||||
@@ -15,7 +16,7 @@ const {TEAM, TEAM_SEARCH_HISTORY} = MM_TABLES.SERVER;
|
||||
* The TeamSearchHistory model holds the term searched within a team. The searches are performed
|
||||
* at team level in the app.
|
||||
*/
|
||||
export default class TeamSearchHistoryModel extends Model {
|
||||
export default class TeamSearchHistoryModel extends Model implements TeamSearchHistoryModelInterface {
|
||||
/** table (name) : TeamSearchHistory */
|
||||
static table = TEAM_SEARCH_HISTORY;
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@ import {field} from '@nozbe/watermelondb/decorators';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type TermsOfServiceModelInterface from '@typings/database/models/servers/terms_of_service';
|
||||
|
||||
const {TERMS_OF_SERVICE} = MM_TABLES.SERVER;
|
||||
|
||||
/**
|
||||
* The model for Terms of Service
|
||||
*/
|
||||
export default class TermsOfServiceModel extends Model {
|
||||
export default class TermsOfServiceModel extends Model implements TermsOfServiceModelInterface {
|
||||
/** table (name) : TermsOfService */
|
||||
static table = TERMS_OF_SERVICE;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type PostModel from '@typings/database/models/servers/post';
|
||||
import type ThreadModelInterface from '@typings/database/models/servers/thread';
|
||||
import type ThreadInTeamModel from '@typings/database/models/servers/thread_in_team';
|
||||
import type ThreadParticipantModel from '@typings/database/models/servers/thread_participant';
|
||||
|
||||
@@ -16,7 +17,7 @@ const {POST, THREAD, THREAD_PARTICIPANT, THREADS_IN_TEAM} = MM_TABLES.SERVER;
|
||||
/**
|
||||
* The Thread model contains thread information of a post.
|
||||
*/
|
||||
export default class ThreadModel extends Model {
|
||||
export default class ThreadModel extends Model implements ThreadModelInterface {
|
||||
/** table (name) : Thread */
|
||||
static table = THREAD;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type TeamModel from '@typings/database/models/servers/team';
|
||||
import type ThreadModel from '@typings/database/models/servers/thread';
|
||||
import type ThreadInTeamModelInterface from '@typings/database/models/servers/thread_in_team';
|
||||
|
||||
const {TEAM, THREAD, THREADS_IN_TEAM} = MM_TABLES.SERVER;
|
||||
|
||||
@@ -16,7 +17,7 @@ const {TEAM, THREAD, THREADS_IN_TEAM} = MM_TABLES.SERVER;
|
||||
* ThreadInTeam model helps us to combine adjacent threads together without leaving
|
||||
* gaps in between for an efficient user reading experience for threads.
|
||||
*/
|
||||
export default class ThreadInTeamModel extends Model {
|
||||
export default class ThreadInTeamModel extends Model implements ThreadInTeamModelInterface {
|
||||
/** table (name) : ThreadsInTeam */
|
||||
static table = THREADS_IN_TEAM;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
import type ThreadModel from '@typings/database/models/servers/thread';
|
||||
import type ThreadParticipantModelInterface from '@typings/database/models/servers/thread_participant';
|
||||
import type UserModel from '@typings/database/models/servers/user';
|
||||
|
||||
const {THREAD, THREAD_PARTICIPANT, USER} = MM_TABLES.SERVER;
|
||||
@@ -15,7 +16,7 @@ const {THREAD, THREAD_PARTICIPANT, USER} = MM_TABLES.SERVER;
|
||||
/**
|
||||
* The Thread Participants model contains participants data of a thread.
|
||||
*/
|
||||
export default class ThreadParticipantModel extends Model {
|
||||
export default class ThreadParticipantModel extends Model implements ThreadParticipantModelInterface {
|
||||
/** table (name) : ThreadParticipant */
|
||||
static table = THREAD_PARTICIPANT;
|
||||
|
||||
@@ -33,7 +34,7 @@ export default class ThreadParticipantModel extends Model {
|
||||
@field('thread_id') threadId!: string;
|
||||
|
||||
/** user_id : user id of the participant. */
|
||||
@field('user_id') userId!: number;
|
||||
@field('user_id') userId!: string;
|
||||
|
||||
/** thread : The related record of the Thread model */
|
||||
@immutableRelation(THREAD, 'thread_id') thread!: Relation<ThreadModel>;
|
||||
|
||||
Reference in New Issue
Block a user