Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@field('archived') archived
@field('join_code_required') joinCodeRequired
@field('notifications') notifications
@field('broadcast') broadcast
// // muted: { type: 'list', objectType: 'usersMuted' },
@date('room_updated_at') roomUpdatedAt
// // lastMessage: { type: 'messages', optional: true },
@lazy
roles = this.collections
.get('roles')
.query(Q.on('subscriptions_roles', 'subscription_id', this.id));
@children('subscriptions_roles') subscriptions_roles
@action deleteRoles() {
this.subscriptions_roles.destroyAllPermanently();
}
@action addRole(roleId) {
return this.collections.get('subscriptions_roles').create((sr) => {
sr.subscriptionId = this.id;
sr.roleId = roleId;
});
}
}
import { Model, Q } from '@nozbe/watermelondb';
import { readonly, date, lazy } from '@nozbe/watermelondb/decorators';
export default class Permission extends Model {
static table = 'permissions'
static associations = {
permission_roles: { type: 'has_many', foreignKey: 'role_id' }
}
@readonly @date('updated_at') updatedAt
@lazy
roles = this.collections
.get('roles')
.query(Q.on('permission_roles', 'permission_id', this.id));
}
static associations = {
permissions_roles: { type: 'has_many', foreignKey: 'permission_id' },
subscriptions_roles: { type: 'has_many', foreignKey: 'subscription_id' }
}
@field('description') description
@lazy
permissions = this.collections
.get('permissions')
.query(Q.on('permissions_roles', 'role_id', this.id));
@lazy
subscriptions = this.collections
.get('subscriptions')
.query(Q.on('subscriptions_roles', 'role_id', this.id));
}
import { field, lazy } from '@nozbe/watermelondb/decorators';
export default class Role extends Model {
static table = 'roles'
static associations = {
permissions_roles: { type: 'has_many', foreignKey: 'permission_id' },
subscriptions_roles: { type: 'has_many', foreignKey: 'subscription_id' }
}
@field('description') description
@lazy
permissions = this.collections
.get('permissions')
.query(Q.on('permissions_roles', 'role_id', this.id));
@lazy
subscriptions = this.collections
.get('subscriptions')
.query(Q.on('subscriptions_roles', 'role_id', this.id));
}
static table = 'blogs'
static associations = {
posts: { type: 'has_many', foreignKey: 'blog_id' },
}
@field('name')
name
@children('posts')
posts
@lazy
nastyComments = this.collections
.get('comments')
.query(Q.on('posts', 'blog_id', this.id), Q.where('is_nasty', true))
@action async moderateAll() {
await this.nastyComments.destroyAllPermanently()
}
}