forked from Ivasoft/mattermost-mobile
* started with the diagrams
* removed redundant tables
next step:
1. reconstruct id ( local id vs server id )
2. annotate fields with examples
3. recreate relationship
* work in progress
* work in progress
* fix association
* update postsInChannel
* removed SlashCommands from the Server database schema
* added missing associations in the models and updated docs/database
* exported server database
* update test
* code corrections following review
* update relationship
* update docs
* removed cyclic relationship
* Revert "removed cyclic relationship"
This reverts commit 4d784efb81.
* removed isOptional from Draft
* linked myChannelSettings to myChannel instead of Channel
* update diagrams
* store null instead of empty string
* update thread association
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {Relation} from '@nozbe/watermelondb';
|
|
import {immutableRelation, json} from '@nozbe/watermelondb/decorators';
|
|
import Model, {Associations} from '@nozbe/watermelondb/Model';
|
|
|
|
import {MM_TABLES} from '@constants/database';
|
|
import {safeParseJSON} from '@utils/helpers';
|
|
|
|
import type MyChannelModel from '@typings/database/models/servers/my_channel';
|
|
import type MyChannelSettingsModelInterface from '@typings/database/models/servers/my_channel_settings';
|
|
|
|
const {MY_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 implements MyChannelSettingsModelInterface {
|
|
/** table (name) : MyChannelSettings */
|
|
static table = MY_CHANNEL_SETTINGS;
|
|
|
|
static associations: Associations = {
|
|
|
|
/** A MY_CHANNEL is associated with one MY_CHANNEL_SETTINGS (relationship is 1:1) **/
|
|
[MY_CHANNEL]: {type: 'belongs_to', key: 'id'},
|
|
};
|
|
|
|
/** notify_props : Configurations in regard to this channel */
|
|
@json('notify_props', safeParseJSON) notifyProps!: ChannelNotifyProps;
|
|
|
|
/** channel : The relation pointing to the MY_CHANNEL table */
|
|
@immutableRelation(MY_CHANNEL, 'id') myChannel!: Relation<MyChannelModel>;
|
|
}
|