forked from Ivasoft/mattermost-mobile
[Gekidou] Groups + group membership schema (#6251)
* First pass at adding groups to mobile * Reverts back and updates the group vars * Cleans tests * Missing created/updated/deleted fields in types, many-many ref fix * Adds to manager * PR Feedback * Failing test * Move FK out of comment, add indexes * updated docs/database/server artefacts Co-authored-by: Avinash Lingaloo <avinashlng1080@gmail.com>
This commit is contained in:
54
types/database/models/servers/group.d.ts
vendored
Normal file
54
types/database/models/servers/group.d.ts
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {Query} from '@nozbe/watermelondb';
|
||||
import {lazy} from '@nozbe/watermelondb/decorators';
|
||||
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
||||
|
||||
import type ChannelModel from './channel';
|
||||
import type TeamModel from './team';
|
||||
import type UserModel from './user';
|
||||
|
||||
/**
|
||||
* A Group is a collection of users, associated to teams and/or channels
|
||||
*/
|
||||
export default class GroupModel extends Model {
|
||||
/** table (name) : Group */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this table. */
|
||||
static associations: Associations;
|
||||
|
||||
/** name : The name of the group */
|
||||
name: string;
|
||||
|
||||
/** display_name : The display name for the group */
|
||||
displayName: string;
|
||||
|
||||
/** description : A short description of the group */
|
||||
description: string;
|
||||
|
||||
/** source : The source of the group */
|
||||
source: string;
|
||||
|
||||
/** remote_id : The remote_id of the group */
|
||||
remoteId: string;
|
||||
|
||||
/** created_at : The timestamp for when it was created */
|
||||
createdAt: number;
|
||||
|
||||
/** updated_at : The timestamp for when it was updated */
|
||||
updatedAt: number;
|
||||
|
||||
/** deleted_at : The timestamp for when it was deleted */
|
||||
deletedAt: number;
|
||||
|
||||
/** channels : All the channels associated with this group */
|
||||
@lazy channels: Query<ChannelModel>;
|
||||
|
||||
/** teams : All the teams associated with this group */
|
||||
@lazy teams: Query<TeamModel>;
|
||||
|
||||
/** members : All the members (users) of this group */
|
||||
@lazy members: Query<UserModel>;
|
||||
}
|
||||
41
types/database/models/servers/group_channel.d.ts
vendored
Normal file
41
types/database/models/servers/group_channel.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 type ChannelModel from './channel';
|
||||
import type GroupModel from './group';
|
||||
|
||||
/**
|
||||
* The GroupChannel model represents the 'association table' where many groups have channels and many channels are in
|
||||
* groups (relationship type N:N)
|
||||
*/
|
||||
export default class GroupChannelModel extends Model {
|
||||
/** table (name) : GroupChannel */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this table. */
|
||||
static associations: Associations;
|
||||
|
||||
/** group_id : The foreign key to the related Group record */
|
||||
groupId: string;
|
||||
|
||||
/* channel_id : The foreign key to the related User record*/
|
||||
channelId: string;
|
||||
|
||||
/** created_at : The timestamp for when it was created */
|
||||
createdAt: number;
|
||||
|
||||
/** updated_at : The timestamp for when it was updated */
|
||||
updatedAt: number;
|
||||
|
||||
/** deleted_at : The timestamp for when it was deleted */
|
||||
deletedAt: number;
|
||||
|
||||
/** group : The related group */
|
||||
group: Relation<GroupModel>;
|
||||
|
||||
/** channel : The related channel */
|
||||
channel: Relation<ChannelModel>;
|
||||
}
|
||||
41
types/database/models/servers/group_membership.d.ts
vendored
Normal file
41
types/database/models/servers/group_membership.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 type GroupModel from './group';
|
||||
import type UserModel from './user';
|
||||
|
||||
/**
|
||||
* The GroupMembership model represents the 'association table' where many groups have users and many users are in
|
||||
* groups (relationship type N:N)
|
||||
*/
|
||||
export default class GroupMembershipModel extends Model {
|
||||
/** table (name) : GroupMembership */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this table. */
|
||||
static associations: Associations;
|
||||
|
||||
/** group_id : The foreign key to the related Group record */
|
||||
groupId: string;
|
||||
|
||||
/* user_id : The foreign key to the related User record*/
|
||||
userId: string;
|
||||
|
||||
/** created_at : The timestamp for when it was created */
|
||||
createdAt: number;
|
||||
|
||||
/** updated_at : The timestamp for when it was updated */
|
||||
updatedAt: number;
|
||||
|
||||
/** deleted_at : The timestamp for when it was deleted */
|
||||
deletedAt: number;
|
||||
|
||||
/** group : The related group */
|
||||
group: Relation<GroupModel>;
|
||||
|
||||
/** user : The related user */
|
||||
member: Relation<UserModel>;
|
||||
}
|
||||
41
types/database/models/servers/group_team.d.ts
vendored
Normal file
41
types/database/models/servers/group_team.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 type GroupModel from './group';
|
||||
import type TeamModel from './team';
|
||||
|
||||
/**
|
||||
* The GroupTeam model represents the 'association table' where many groups have teams and many teams are in
|
||||
* groups (relationship type N:N)
|
||||
*/
|
||||
export default class GroupTeamModel extends Model {
|
||||
/** table (name) : GroupTeam */
|
||||
static table: string;
|
||||
|
||||
/** associations : Describes every relationship to this table. */
|
||||
static associations: Associations;
|
||||
|
||||
/** group_id : The foreign key to the related Group record */
|
||||
groupId: string;
|
||||
|
||||
/* team_id : The foreign key to the related Team record*/
|
||||
teamId: string;
|
||||
|
||||
/** created_at : The timestamp for when it was created */
|
||||
createdAt: number;
|
||||
|
||||
/** updated_at : The timestamp for when it was updated */
|
||||
updatedAt: number;
|
||||
|
||||
/** deleted_at : The timestamp for when it was deleted */
|
||||
deletedAt: number;
|
||||
|
||||
/** group : The related group */
|
||||
group: Relation<GroupModel>;
|
||||
|
||||
/** team : The related team */
|
||||
team: Relation<TeamModel>;
|
||||
}
|
||||
4
types/database/raw_values.d.ts
vendored
4
types/database/raw_values.d.ts
vendored
@@ -99,6 +99,10 @@ type RawValue =
|
||||
| CustomEmoji
|
||||
| Draft
|
||||
| FileInfo
|
||||
| Group
|
||||
| GroupChannel
|
||||
| GroupTeam
|
||||
| GroupMembership
|
||||
| IdValue
|
||||
| Metadata
|
||||
| MyTeam
|
||||
|
||||
Reference in New Issue
Block a user