mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 02:15:21 +00:00
community user relation
This commit is contained in:
@ -2,6 +2,8 @@ import {
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
Unique,
|
||||
@ -26,6 +28,7 @@ import { OtpType } from '../../../../src/constants/otp-type.enum';
|
||||
import { RoleTypeEntity } from '../../role-type/entities';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
import { VisitorPasswordEntity } from '../../visitor-password/entities';
|
||||
import { CommunityEntity } from '../../community/entities';
|
||||
|
||||
@Entity({ name: 'user' })
|
||||
export class UserEntity extends AbstractEntity<UserDto> {
|
||||
@ -115,6 +118,15 @@ export class UserEntity extends AbstractEntity<UserDto> {
|
||||
(visitorPassword) => visitorPassword.user,
|
||||
)
|
||||
public visitorPasswords: VisitorPasswordEntity[];
|
||||
|
||||
@ManyToMany(() => CommunityEntity, (community) => community.users)
|
||||
@JoinTable({
|
||||
name: 'user_communities', // Join table to link users and communities
|
||||
joinColumn: { name: 'user_id', referencedColumnName: 'uuid' },
|
||||
inverseJoinColumn: { name: 'community_id', referencedColumnName: 'uuid' },
|
||||
})
|
||||
communities: CommunityEntity[];
|
||||
|
||||
constructor(partial: Partial<UserEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
Reference in New Issue
Block a user