forked from Ivasoft/mattermost-mobile
MM_30476 [v2] Section 'Channel' of the server schema (#5078)
* MM_30476 : Added all isolated tables from the server schema * MM_30476 : Updated 'test' script in package.json * MM_30476 : Rename table schemas to avoid name collision * MM_30476 : Added 'Channel' section of the server schema * MM_30476 : Apply suggestions from code review Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * MM_30476 : Converted @relation to @immutableRelation * MM_30476 : Apply suggestions from code review * MM_30476 : Apply suggestions from code review Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> * MM_30476 : Minor updates to the comments * MM_30476 : Minor update to the comments * MM_30476 : Updated table schema exports * MM_30476 : Updated comments * MM_30476 : Apply suggestions from code review Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * MM_30476 : Update as per suggestions * MM_30476 : Updated comments * MM_30476 : Team and MyTeam share 1:1 relationship * MM_30476 : Updated team comments * MM_30476 : Updated myteam and team comments Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com> Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
131
app/database/server/models/channel.ts
Normal file
131
app/database/server/models/channel.ts
Normal file
@@ -0,0 +1,131 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {Q, Query, Relation} from '@nozbe/watermelondb';
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
import {children, field, immutableRelation, lazy} from '@nozbe/watermelondb/decorators';
|
||||
import ChannelInfo from '@typings/database/channel_info';
|
||||
|
||||
import ChannelMembership from '@typings/database/channel_membership';
|
||||
import Draft from '@typings/database/draft';
|
||||
import GroupsInChannel from '@typings/database/groups_in_channel';
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import MyChannel from '@typings/database/my_channel';
|
||||
import MyChannelSettings from '@typings/database/my_channel_settings';
|
||||
import Post from '@typings/database/post';
|
||||
import PostsInChannel from '@typings/database/posts_in_channel';
|
||||
import Team from '@typings/database/team';
|
||||
import User from '@typings/database/user';
|
||||
|
||||
const {
|
||||
CHANNEL,
|
||||
CHANNEL_INFO,
|
||||
CHANNEL_MEMBERSHIP,
|
||||
DRAFT,
|
||||
GROUPS_IN_CHANNEL,
|
||||
MY_CHANNEL,
|
||||
MY_CHANNEL_SETTINGS,
|
||||
POSTS_IN_CHANNEL,
|
||||
POST,
|
||||
TEAM,
|
||||
USER,
|
||||
} = MM_TABLES.SERVER;
|
||||
|
||||
/**
|
||||
* The Channel model represents a channel in the Mattermost app.
|
||||
*/
|
||||
export default class Channel extends Model {
|
||||
/** table (entity name) : Channel */
|
||||
static table = CHANNEL;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations = {
|
||||
|
||||
/** A CHANNEL is associated with only one CHANNEL_INFO (relationship is 1:1) */
|
||||
[CHANNEL_INFO]: {type: 'has_many', foreignKey: 'channel_id'},
|
||||
|
||||
/** A CHANNEL can be associated with multiple CHANNEL_MEMBERSHIP (relationship is 1:N) */
|
||||
[CHANNEL_MEMBERSHIP]: {type: 'has_many', foreignKey: 'channel_id'},
|
||||
|
||||
/** A CHANNEL can be associated with multiple DRAFT (relationship is 1:N) */
|
||||
[DRAFT]: {type: 'has_many', foreignKey: 'channel_id'},
|
||||
|
||||
/** A CHANNEL can be associated with multiple GROUPS_IN_CHANNEL (relationship is 1:N) */
|
||||
[GROUPS_IN_CHANNEL]: {type: 'has_many', foreignKey: 'channel_id'},
|
||||
|
||||
/** A CHANNEL is associated with only one MY_CHANNEL (relationship is 1:1) */
|
||||
[MY_CHANNEL]: {type: 'has_many', foreignKey: 'channel_id'},
|
||||
|
||||
/** A CHANNEL is associated to only one MY_CHANNEL_SETTINGS (relationship is 1:1) */
|
||||
[MY_CHANNEL_SETTINGS]: {type: 'has_many', foreignKey: 'channel_id'},
|
||||
|
||||
/** A CHANNEL can be associated with multiple POSTS_IN_CHANNEL (relationship is 1:N) */
|
||||
[POSTS_IN_CHANNEL]: {type: 'has_many', foreignKey: 'channel_id'},
|
||||
|
||||
/** A CHANNEL can contain multiple POST (relationship is 1:N) */
|
||||
[POST]: {type: 'has_many', foreignKey: 'channel_id'},
|
||||
|
||||
/** A TEAM can be associated to CHANNEL (relationship is 1:N) */
|
||||
[TEAM]: {type: 'belongs_to', key: 'team_id'},
|
||||
|
||||
/** A USER can create multiple CHANNEL (relationship is 1:N) */
|
||||
[USER]: {type: 'belongs_to', key: 'creator_id'},
|
||||
};
|
||||
|
||||
/** create_at : The creation date for this channel */
|
||||
@field('create_at') createAt!: number;
|
||||
|
||||
/** creator_id : The user who created this channel */
|
||||
@field('creator_id') creatorId!: string;
|
||||
|
||||
/** delete_at : The deletion/archived date of this channel */
|
||||
@field('delete_at') deleteAt!: number;
|
||||
|
||||
/** display_name : The channel display name (e.g. Town Square ) */
|
||||
@field('display_name') displayName!: string;
|
||||
|
||||
/** is_group_constrained : If a channel is restricted to certain groups, this boolean will be true and only
|
||||
* members of that group have access to this team. Hence indicating that the members of this channel are
|
||||
* managed by groups.
|
||||
*/
|
||||
@field('is_group_constrained') isGroupConstrained!: boolean;
|
||||
|
||||
/** name : The name of the channel (e.g town-square) */
|
||||
@field('name') name!: string;
|
||||
|
||||
/** team_id : The team to which this channel belongs. It can be empty for direct/group message. */
|
||||
@field('team_id') teamId!: string;
|
||||
|
||||
/** type : The type of the channel ( e.g. G: group messages, D: direct messages, P: private channel and O: public channel) */
|
||||
@field('type') type!: string;
|
||||
|
||||
/** members : Users belonging to this channel */
|
||||
@children(CHANNEL_MEMBERSHIP) members!: ChannelMembership[];
|
||||
|
||||
/** drafts : All drafts for this channel */
|
||||
@children(DRAFT) drafts!: Draft[];
|
||||
|
||||
/** groupsInChannel : Every group contained in this channel */
|
||||
@children(GROUPS_IN_CHANNEL) groupsInChannel!: GroupsInChannel[];
|
||||
|
||||
/** posts : All posts made in that channel */
|
||||
@children(POST) posts!: Post[];
|
||||
|
||||
/** postsInChannel : a section of the posts for that channel bounded by a range */
|
||||
@children(POSTS_IN_CHANNEL) postsInChannel!: PostsInChannel[];
|
||||
|
||||
/** team : The TEAM to which this CHANNEL belongs */
|
||||
@immutableRelation(TEAM, 'team_id') team!: Relation<Team>;
|
||||
|
||||
/** creator : The USER who created this CHANNEL*/
|
||||
@immutableRelation(USER, 'creator_id') creator!: Relation<User>;
|
||||
|
||||
/** info : Query returning extra information about this channel from entity CHANNEL_INFO */
|
||||
@lazy info = this.collections.get(CHANNEL_INFO).query(Q.on(CHANNEL, 'id', this.id)) as Query<ChannelInfo>;
|
||||
|
||||
/** membership : Query returning the membership data for the current user if it belongs to this channel */
|
||||
@lazy membership = this.collections.get(MY_CHANNEL).query(Q.on(CHANNEL, 'id', this.id)) as Query<MyChannel>;
|
||||
|
||||
/** settings: User specific settings/preferences for this channel */
|
||||
@lazy settings = this.collections.get(MY_CHANNEL_SETTINGS).query(Q.on(CHANNEL, 'id', this.id)) as Query<MyChannelSettings>;
|
||||
}
|
||||
49
app/database/server/models/channel_info.ts
Normal file
49
app/database/server/models/channel_info.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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 Channel from '@typings/database/channel';
|
||||
|
||||
const {CHANNEL, CHANNEL_INFO} = MM_TABLES.SERVER;
|
||||
|
||||
/**
|
||||
* ChannelInfo is an extension of the information contained in the Channel entity.
|
||||
* In a Separation of Concerns approach, ChannelInfo will provide additional information about a channel but on a more
|
||||
* specific level.
|
||||
*/
|
||||
export default class ChannelInfo extends Model {
|
||||
/** table (entity name) : ChannelInfo */
|
||||
static table = CHANNEL_INFO;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations = {
|
||||
|
||||
/** A CHANNEL is associated with only one CHANNEL_INFO (relationship is 1:1) */
|
||||
[CHANNEL]: {type: 'belongs_to', key: 'channel_id'},
|
||||
};
|
||||
|
||||
/** channel_id : The foreign key from CHANNEL */
|
||||
@field('channel_id') channelId!: string;
|
||||
|
||||
/** guest_count : The number of guest in this channel */
|
||||
@field('guest_count') guestCount!: number;
|
||||
|
||||
/** header : The headers at the top of each channel */
|
||||
@field('header') header!: string;
|
||||
|
||||
/** member_count: The number of members in this channel */
|
||||
@field('member_count') memberCount!: number;
|
||||
|
||||
/** pinned_post_count : The number of post pinned in this channel */
|
||||
@field('pinned_post_count') pinnedPostCount!: number;
|
||||
|
||||
/** purpose: The intention behind this channel */
|
||||
@field('purpose') purpose!: string;
|
||||
|
||||
/** channel : The lazy query property to the record from entity CHANNEL */
|
||||
@immutableRelation(CHANNEL, 'channel_id') channel!: Relation<Channel>
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
export {default as ChannelInfo} from './channel_info';
|
||||
export {default as ChannelMembership} from './channel_membership';
|
||||
export {default as Channel} from './channel';
|
||||
export {default as CustomEmoji} from './custom_emoji';
|
||||
export {default as Draft} from './draft';
|
||||
export {default as File} from './file';
|
||||
@@ -9,8 +11,11 @@ export {default as GroupMembership} from './group_membership';
|
||||
export {default as GroupsInChannel} from './groups_in_channel';
|
||||
export {default as GroupsInTeam} from './groups_in_team';
|
||||
export {default as Group} from './group';
|
||||
export {default as MyChannelSettings} from './my_channel_settings';
|
||||
export {default as MyChannel} from './my_channel';
|
||||
export {default as MyTeam} from './my_team';
|
||||
export {default as PostMetadata} from './post_metadata';
|
||||
export {default as PostsInChannel} from './posts_in_channel';
|
||||
export {default as PostsInThread} from './posts_in_thread';
|
||||
export {default as Post} from './post';
|
||||
export {default as Preference} from './preference';
|
||||
|
||||
47
app/database/server/models/my_channel.ts
Normal file
47
app/database/server/models/my_channel.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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 Channel from '@typings/database/channel';
|
||||
|
||||
const {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 MyChannel extends Model {
|
||||
/** table (entity name) : MyChannel */
|
||||
static table = MY_CHANNEL;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations = {
|
||||
|
||||
/** A CHANNEL can be associated to only one record from entity MY_CHANNEL (relationship is 1:1) */
|
||||
[CHANNEL]: {type: 'belongs_to', key: 'channel_id'},
|
||||
};
|
||||
|
||||
/** channel_id : The foreign key to the related Channel record */
|
||||
@field('channel_id') channelId!: string;
|
||||
|
||||
/** last_post_at : The timestamp for any last post on this channel */
|
||||
@field('last_post_at') lastPostAt!: number;
|
||||
|
||||
/** last_viewed_at : The timestamp showing the user's last viewed post on this channel */
|
||||
@field('last_viewed_at') lastViewedAt!: number;
|
||||
|
||||
/** mentions_count : The number of mentions on this channel */
|
||||
@field('mentions_count') mentionsCount!: number;
|
||||
|
||||
/** message_count : The derived number of unread messages on this channel */
|
||||
@field('message_count') messageCount!: number;
|
||||
|
||||
/** roles : The user's privileges on this channel */
|
||||
@field('roles') roles!: string;
|
||||
|
||||
/** channel : The relation pointing to entity CHANNEL */
|
||||
@immutableRelation(CHANNEL, 'channel_id') channel!: Relation<Channel>
|
||||
}
|
||||
36
app/database/server/models/my_channel_settings.ts
Normal file
36
app/database/server/models/my_channel_settings.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
// 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, json, immutableRelation} from '@nozbe/watermelondb/decorators';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import Channel from '@typings/database/channel';
|
||||
|
||||
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 MyChannelSettings extends Model {
|
||||
/** table (entity name) : MyChannelSettings */
|
||||
static table = MY_CHANNEL_SETTINGS;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations = {
|
||||
|
||||
/** A CHANNEL is related to only one MY_CHANNEL_SETTINGS (relationship is 1:1) */
|
||||
[CHANNEL]: {type: 'belongs_to', key: 'channel_id'},
|
||||
};
|
||||
|
||||
/** channel_id : The foreign key to the related CHANNEL record */
|
||||
@field('channel_id') channelId!: string;
|
||||
|
||||
/** notify_props : Configurations with regards to this channel */
|
||||
@json('notify_props', (rawJson) => rawJson) notifyProps!: NotifyProps;
|
||||
|
||||
/** channel : The relation pointing to entity CHANNEL */
|
||||
@immutableRelation(CHANNEL, 'channel_id') channel!: Relation<Channel>;
|
||||
}
|
||||
39
app/database/server/models/posts_in_channel.ts
Normal file
39
app/database/server/models/posts_in_channel.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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 Channel from '@typings/database/channel';
|
||||
|
||||
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 PostsInChannel extends Model {
|
||||
/** table (entity name) : PostsInChannel */
|
||||
static table = POSTS_IN_CHANNEL;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations = {
|
||||
|
||||
/** A CHANNEL can have multiple POSTS_IN_CHANNEL. (relationship is 1:N)*/
|
||||
[CHANNEL]: {type: 'belongs_to', key: 'channel_id'},
|
||||
};
|
||||
|
||||
/** channel_id : The foreign key of the related parent channel */
|
||||
@field('channel_id') channelId!: string;
|
||||
|
||||
/** earliest : The earliest timestamp of the post in that channel */
|
||||
@field('earliest') earliest!: number;
|
||||
|
||||
/** latest : The latest timestamp of the post in that channel */
|
||||
@field('latest') latest!: number;
|
||||
|
||||
/** channel : The parent record of the channel for those posts */
|
||||
@immutableRelation(CHANNEL, 'channel_id') channel!: Relation<Channel>;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ export default class Reaction extends Model {
|
||||
[USER]: {type: 'belongs_to', key: 'user_id'},
|
||||
};
|
||||
|
||||
/** createAt : Creation timestamp used for sorting reactions amongst users on a particular post */
|
||||
/** create_at : Creation timestamp used for sorting reactions amongst users on a particular post */
|
||||
@field('create_at') createAt!: number;
|
||||
|
||||
/** emoji_name : The emoticon used to express the reaction */
|
||||
|
||||
@@ -87,7 +87,7 @@ export default class Team extends Model {
|
||||
/** groupsInTeam : All the groups associated with this team */
|
||||
@children(GROUPS_IN_TEAM) groupsInTeam!: GroupsInTeam[];
|
||||
|
||||
/** myTeam : Lazy query property returning only the team member that this user is part of */
|
||||
/** myTeam : Retrieves additional information about the team that this user is possibly part of. This query might yield no result if the user isn't part of a team. */
|
||||
@lazy myTeam = this.collections.get(MY_TEAM).query(Q.on(TEAM, 'id', this.id)) as Query<MyTeam>;
|
||||
|
||||
/** slashCommands : All the slash commands associated with this team */
|
||||
|
||||
@@ -28,7 +28,7 @@ export default class TeamChannelHistory extends Model {
|
||||
/** team_id : The foreign key to the related Team record */
|
||||
@field('team_id') teamId!: string;
|
||||
|
||||
/** channelIds : An array containing the last 5 channels visited within this team order by recency */
|
||||
/** channel_ids : An array containing the last 5 channels visited within this team order by recency */
|
||||
@json('channel_ids', (rawJson) => rawJson) channelIds!: string[];
|
||||
|
||||
/** team : The related record from the parent Team model */
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {AppSchema, appSchema} from '@nozbe/watermelondb';
|
||||
|
||||
import {
|
||||
ChannelInfoSchema,
|
||||
ChannelMembershipSchema,
|
||||
ChannelSchema,
|
||||
CustomEmojiSchema,
|
||||
DraftSchema,
|
||||
FileSchema,
|
||||
@@ -11,10 +14,13 @@ import {
|
||||
GroupSchema,
|
||||
GroupsInChannelSchema,
|
||||
GroupsInTeamSchema,
|
||||
MyChannelSchema,
|
||||
MyChannelSettingsSchema,
|
||||
MyTeamSchema,
|
||||
PostInThreadSchema,
|
||||
PostMetadataSchema,
|
||||
PostSchema,
|
||||
PostsInChannelSchema,
|
||||
PreferenceSchema,
|
||||
ReactionSchema,
|
||||
RoleSchema,
|
||||
@@ -31,7 +37,9 @@ import {
|
||||
export const serverSchema: AppSchema = appSchema({
|
||||
version: 1,
|
||||
tables: [
|
||||
ChannelInfoSchema,
|
||||
ChannelMembershipSchema,
|
||||
ChannelSchema,
|
||||
CustomEmojiSchema,
|
||||
DraftSchema,
|
||||
FileSchema,
|
||||
@@ -39,7 +47,10 @@ export const serverSchema: AppSchema = appSchema({
|
||||
GroupSchema,
|
||||
GroupsInChannelSchema,
|
||||
GroupsInTeamSchema,
|
||||
MyChannelSchema,
|
||||
MyChannelSettingsSchema,
|
||||
MyTeamSchema,
|
||||
PostsInChannelSchema,
|
||||
PostInThreadSchema,
|
||||
PostMetadataSchema,
|
||||
PostSchema,
|
||||
|
||||
22
app/database/server/schema/table_schemas/channel.ts
Normal file
22
app/database/server/schema/table_schemas/channel.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {tableSchema} from '@nozbe/watermelondb';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {CHANNEL} = MM_TABLES.SERVER;
|
||||
|
||||
export default tableSchema({
|
||||
name: CHANNEL,
|
||||
columns: [
|
||||
{name: 'create_at', type: 'number'},
|
||||
{name: 'creator_id', type: 'string', isIndexed: true},
|
||||
{name: 'delete_at', type: 'number'},
|
||||
{name: 'display_name', type: 'string'},
|
||||
{name: 'is_group_constrained', type: 'boolean'},
|
||||
{name: 'name', type: 'string', isIndexed: true},
|
||||
{name: 'team_id', type: 'string', isIndexed: true},
|
||||
{name: 'type', type: 'string'},
|
||||
],
|
||||
});
|
||||
20
app/database/server/schema/table_schemas/channel_info.ts
Normal file
20
app/database/server/schema/table_schemas/channel_info.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {tableSchema} from '@nozbe/watermelondb';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {CHANNEL_INFO} = MM_TABLES.SERVER;
|
||||
|
||||
export default tableSchema({
|
||||
name: CHANNEL_INFO,
|
||||
columns: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
{name: 'guest_count', type: 'number'},
|
||||
{name: 'header', type: 'string'},
|
||||
{name: 'member_count', type: 'number'},
|
||||
{name: 'pinned_post_count', type: 'number'},
|
||||
{name: 'purpose', type: 'string'},
|
||||
],
|
||||
});
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
export {default as ChannelInfoSchema} from './channel_info';
|
||||
export {default as ChannelMembershipSchema} from './channel_membership';
|
||||
export {default as ChannelSchema} from './channel';
|
||||
export {default as CustomEmojiSchema} from './custom_emoji';
|
||||
export {default as DraftSchema} from './draft';
|
||||
export {default as FileSchema} from './file';
|
||||
@@ -9,7 +11,10 @@ export {default as GroupMembershipSchema} from './group_membership';
|
||||
export {default as GroupSchema} from './group';
|
||||
export {default as GroupsInChannelSchema} from './groups_in_channel';
|
||||
export {default as GroupsInTeamSchema} from './groups_in_team';
|
||||
export {default as MyChannelSchema} from './my_channel';
|
||||
export {default as MyChannelSettingsSchema} from './my_channel_settings';
|
||||
export {default as MyTeamSchema} from './my_team';
|
||||
export {default as PostsInChannelSchema} from './posts_in_channel';
|
||||
export {default as PostInThreadSchema} from './posts_in_thread';
|
||||
export {default as PostMetadataSchema} from './post_metadata';
|
||||
export {default as PostSchema} from './post';
|
||||
|
||||
20
app/database/server/schema/table_schemas/my_channel.ts
Normal file
20
app/database/server/schema/table_schemas/my_channel.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {tableSchema} from '@nozbe/watermelondb';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {MY_CHANNEL} = MM_TABLES.SERVER;
|
||||
|
||||
export default tableSchema({
|
||||
name: MY_CHANNEL,
|
||||
columns: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
{name: 'last_post_at', type: 'number'},
|
||||
{name: 'last_viewed_at', type: 'number'},
|
||||
{name: 'mentions_count', type: 'number'},
|
||||
{name: 'message_count', type: 'number'},
|
||||
{name: 'roles', type: 'string'},
|
||||
],
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {tableSchema} from '@nozbe/watermelondb';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {MY_CHANNEL_SETTINGS} = MM_TABLES.SERVER;
|
||||
|
||||
export default tableSchema({
|
||||
name: MY_CHANNEL_SETTINGS,
|
||||
columns: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
{name: 'notify_props', type: 'string'},
|
||||
],
|
||||
});
|
||||
17
app/database/server/schema/table_schemas/posts_in_channel.ts
Normal file
17
app/database/server/schema/table_schemas/posts_in_channel.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {tableSchema} from '@nozbe/watermelondb';
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
|
||||
const {POSTS_IN_CHANNEL} = MM_TABLES.SERVER;
|
||||
|
||||
export default tableSchema({
|
||||
name: POSTS_IN_CHANNEL,
|
||||
columns: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
{name: 'earliest', type: 'number'},
|
||||
{name: 'latest', type: 'number'},
|
||||
],
|
||||
});
|
||||
@@ -5,6 +5,8 @@ import {MM_TABLES} from '@constants/database';
|
||||
import {serverSchema} from './index';
|
||||
|
||||
const {
|
||||
CHANNEL,
|
||||
CHANNEL_INFO,
|
||||
CHANNEL_MEMBERSHIP,
|
||||
CUSTOM_EMOJI,
|
||||
DRAFT,
|
||||
@@ -13,8 +15,11 @@ const {
|
||||
GROUPS_IN_CHANNEL,
|
||||
GROUPS_IN_TEAM,
|
||||
GROUP_MEMBERSHIP,
|
||||
MY_CHANNEL,
|
||||
MY_CHANNEL_SETTINGS,
|
||||
MY_TEAM,
|
||||
POST,
|
||||
POSTS_IN_CHANNEL,
|
||||
POSTS_IN_THREAD,
|
||||
POST_METADATA,
|
||||
PREFERENCE,
|
||||
@@ -35,6 +40,48 @@ describe('*** Test schema for SERVER database ***', () => {
|
||||
expect(serverSchema).toEqual({
|
||||
version: 1,
|
||||
tables: {
|
||||
[CHANNEL_INFO]: {
|
||||
name: CHANNEL_INFO,
|
||||
columns: {
|
||||
channel_id: {name: 'channel_id', type: 'string', isIndexed: true},
|
||||
guest_count: {name: 'guest_count', type: 'number'},
|
||||
header: {name: 'header', type: 'string'},
|
||||
member_count: {name: 'member_count', type: 'number'},
|
||||
pinned_post_count: {name: 'pinned_post_count', type: 'number'},
|
||||
purpose: {name: 'purpose', type: 'string'},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
{name: 'guest_count', type: 'number'},
|
||||
{name: 'header', type: 'string'},
|
||||
{name: 'member_count', type: 'number'},
|
||||
{name: 'pinned_post_count', type: 'number'},
|
||||
{name: 'purpose', type: 'string'},
|
||||
],
|
||||
},
|
||||
[CHANNEL]: {
|
||||
name: CHANNEL,
|
||||
columns: {
|
||||
create_at: {name: 'create_at', type: 'number'},
|
||||
creator_id: {name: 'creator_id', type: 'string', isIndexed: true},
|
||||
delete_at: {name: 'delete_at', type: 'number'},
|
||||
display_name: {name: 'display_name', type: 'string'},
|
||||
is_group_constrained: {name: 'is_group_constrained', type: 'boolean'},
|
||||
name: {name: 'name', type: 'string', isIndexed: true},
|
||||
team_id: {name: 'team_id', type: 'string', isIndexed: true},
|
||||
type: {name: 'type', type: 'string'},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'create_at', type: 'number'},
|
||||
{name: 'creator_id', type: 'string', isIndexed: true},
|
||||
{name: 'delete_at', type: 'number'},
|
||||
{name: 'display_name', type: 'string'},
|
||||
{name: 'is_group_constrained', type: 'boolean'},
|
||||
{name: 'name', type: 'string', isIndexed: true},
|
||||
{name: 'team_id', type: 'string', isIndexed: true},
|
||||
{name: 'type', type: 'string'},
|
||||
],
|
||||
},
|
||||
[CHANNEL_MEMBERSHIP]: {
|
||||
name: CHANNEL_MEMBERSHIP,
|
||||
columns: {
|
||||
@@ -55,6 +102,50 @@ describe('*** Test schema for SERVER database ***', () => {
|
||||
{name: 'name', type: 'string'},
|
||||
],
|
||||
},
|
||||
[MY_CHANNEL]: {
|
||||
name: MY_CHANNEL,
|
||||
columns: {
|
||||
channel_id: {name: 'channel_id', type: 'string', isIndexed: true},
|
||||
last_post_at: {name: 'last_post_at', type: 'number'},
|
||||
last_viewed_at: {name: 'last_viewed_at', type: 'number'},
|
||||
mentions_count: {name: 'mentions_count', type: 'number'},
|
||||
message_count: {name: 'message_count', type: 'number'},
|
||||
roles: {name: 'roles', type: 'string'},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
{name: 'last_post_at', type: 'number'},
|
||||
{name: 'last_viewed_at', type: 'number'},
|
||||
{name: 'mentions_count', type: 'number'},
|
||||
{name: 'message_count', type: 'number'},
|
||||
{name: 'roles', type: 'string'},
|
||||
],
|
||||
},
|
||||
[MY_CHANNEL_SETTINGS]: {
|
||||
name: MY_CHANNEL_SETTINGS,
|
||||
columns: {
|
||||
channel_id: {name: 'channel_id', type: 'string', isIndexed: true},
|
||||
notify_props: {name: 'notify_props', type: 'string'},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
{name: 'notify_props', type: 'string'},
|
||||
],
|
||||
},
|
||||
[POSTS_IN_CHANNEL]: {
|
||||
name: POSTS_IN_CHANNEL,
|
||||
columns: {
|
||||
channel_id: {name: 'channel_id', type: 'string', isIndexed: true},
|
||||
earliest: {name: 'earliest', type: 'number'},
|
||||
latest: {name: 'latest', type: 'number'},
|
||||
},
|
||||
columnArray: [
|
||||
{name: 'channel_id', type: 'string', isIndexed: true},
|
||||
{name: 'earliest', type: 'number'},
|
||||
{name: 'latest', type: 'number'},
|
||||
|
||||
],
|
||||
},
|
||||
[DRAFT]: {
|
||||
name: DRAFT,
|
||||
columns: {
|
||||
|
||||
4
types/database/channel.d.ts
vendored
4
types/database/channel.d.ts
vendored
@@ -52,13 +52,13 @@ export default class Channel extends Model {
|
||||
/** members : Users belonging to this channel */
|
||||
members: ChannelMembership[];
|
||||
|
||||
/** draft : All drafts for this channel */
|
||||
/** drafts : All drafts for this channel */
|
||||
drafts: Draft[];
|
||||
|
||||
/** groupsInChannel : Every group contained in this channel */
|
||||
groupsInChannel: GroupsInChannel[];
|
||||
|
||||
/** posts : all posts made in the channel */
|
||||
/** posts : All posts made in the channel */
|
||||
posts: Post[];
|
||||
|
||||
/** postsInChannel : a section of the posts for that channel bounded by a range */
|
||||
|
||||
41
types/database/channel_info.d.ts
vendored
Normal file
41
types/database/channel_info.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// 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 Channel from '@typings/database/channel';
|
||||
|
||||
/**
|
||||
* ChannelInfo is an extension of the information contained in the Channel entity.
|
||||
* In a Separation of Concerns approach, ChannelInfo will provide additional information about a channel but on a more
|
||||
* specific level.
|
||||
*/
|
||||
export default class ChannelInfo extends Model {
|
||||
/** table (entity name) : ChannelInfo */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** channel_id : The foreign key from CHANNEL */
|
||||
channelId: string;
|
||||
|
||||
/** guest_count : The number of guest in this channel */
|
||||
guestCount: number;
|
||||
|
||||
/** header : The headers at the top of each channel */
|
||||
header: string;
|
||||
|
||||
/** member_count: The number of members in this channel */
|
||||
memberCount: number;
|
||||
|
||||
/** pinned_post_count : The number of post pinned in this channel */
|
||||
pinned_post_count: number;
|
||||
|
||||
/** purpose: The intention behind this channel */
|
||||
purpose: string;
|
||||
|
||||
/** channel : The lazy query property to the record from entity CHANNEL */
|
||||
channel: Relation<Channel>;
|
||||
}
|
||||
2
types/database/channel_membership.d.ts
vendored
2
types/database/channel_membership.d.ts
vendored
@@ -20,6 +20,8 @@ export default class ChannelMembership extends Model {
|
||||
|
||||
/** channel_id : The foreign key to the related Channel record */
|
||||
channelId: string;
|
||||
|
||||
/* user_id: The foreign key to the related User record*/
|
||||
userId: string;
|
||||
|
||||
/** memberChannel : The related channel this member belongs to */
|
||||
|
||||
39
types/database/my_channel.d.ts
vendored
Normal file
39
types/database/my_channel.d.ts
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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 Channel from '@typings/database/channel';
|
||||
|
||||
/**
|
||||
* MyChannel is an extension of the Channel model but it lists only the Channels the app's user belongs to
|
||||
*/
|
||||
export default class MyChannel extends Model {
|
||||
/** table (entity name) : MyChannel */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** channel_id : The foreign key to the related Channel record */
|
||||
channelId: string;
|
||||
|
||||
/** last_post_at : The timestamp for any last post on this channel */
|
||||
lastPostAt: number;
|
||||
|
||||
/** last_viewed_at : The timestamp showing the user's last viewed post on this channel */
|
||||
lastViewedAt: number;
|
||||
|
||||
/** mentions_count : The number of mentions on this channel */
|
||||
mentionsCount: number;
|
||||
|
||||
/** message_count : The derived number of unread messages on this channel */
|
||||
messageCount: number;
|
||||
|
||||
/** roles : The user's privileges on this channel */
|
||||
roles: string;
|
||||
|
||||
/** channel : The relation pointing to entity CHANNEL */
|
||||
channel: Relation<Channel>;
|
||||
}
|
||||
28
types/database/my_channel_settings.d.ts
vendored
Normal file
28
types/database/my_channel_settings.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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 Channel from '@typings/database/channel';
|
||||
|
||||
/**
|
||||
* The MyChannelSettings model represents the specific user's configuration to
|
||||
* the channel this user belongs to.
|
||||
*/
|
||||
export default class MyChannelSettings extends Model {
|
||||
/** table (entity name) : MyChannelSettings */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** channel_id : The foreign key to the related CHANNEL record */
|
||||
channelId: string;
|
||||
|
||||
/** notify_props : Configurations with regards to this channel */
|
||||
notifyProps: NotifyProps;
|
||||
|
||||
/** channel : The relation pointing to entity CHANNEL */
|
||||
channel: Relation<Channel>;
|
||||
}
|
||||
2
types/database/reaction.d.ts
vendored
2
types/database/reaction.d.ts
vendored
@@ -17,7 +17,7 @@ export default class Reaction extends Model {
|
||||
/** associations : Describes every relationship to this entity. */
|
||||
static associations: Associations;
|
||||
|
||||
/** createAt : Creation timestamp used for sorting reactions amongst users on a particular post */
|
||||
/** create_at : Creation timestamp used for sorting reactions amongst users on a particular post */
|
||||
createAt: number;
|
||||
|
||||
/** emoji_name : The emoticon used to express the reaction */
|
||||
|
||||
2
types/database/team.d.ts
vendored
2
types/database/team.d.ts
vendored
@@ -52,7 +52,7 @@ export default class Team extends Model {
|
||||
/** groupsInTeam : All the groups associated with this team */
|
||||
groupsInTeam: GroupsInTeam[];
|
||||
|
||||
/** myTeam : Lazy query property returning only the team member that this user is part of */
|
||||
/** myTeam : Retrieves additional information about the team that this user is possibly part of. This query might yield no result if the user isn't part of a team. */
|
||||
myTeam: Query<MyTeam>;
|
||||
|
||||
/** slashCommands : All the slash commands associated with this team */
|
||||
|
||||
2
types/database/team_channel_history.d.ts
vendored
2
types/database/team_channel_history.d.ts
vendored
@@ -20,7 +20,7 @@ export default class TeamChannelHistory extends Model {
|
||||
/** team_id : The foreign key to the related Team record */
|
||||
teamId: string;
|
||||
|
||||
/** channelIds : An array containing the last 5 channels visited within this team order by recency */
|
||||
/** channel_ids : An array containing the last 5 channels visited within this team order by recency */
|
||||
channelIds: string[];
|
||||
|
||||
/** team : The related record from the parent Team model */
|
||||
|
||||
Reference in New Issue
Block a user