add relation from user->user_profile to speed up UserEntityService.pack and packMany
This commit is contained in:
@@ -8,6 +8,7 @@ import { type UserUnsignedFetchOption, userUnsignedFetchOptions } from '@/const.
|
||||
import { MiInstance } from '@/models/Instance.js';
|
||||
import { id } from './util/id.js';
|
||||
import { MiDriveFile } from './DriveFile.js';
|
||||
import type { MiUserProfile } from './UserProfile.js';
|
||||
|
||||
@Entity('user')
|
||||
@Index(['usernameLower', 'host'], { unique: true })
|
||||
@@ -395,6 +396,9 @@ export class MiUser {
|
||||
})
|
||||
public attributionDomains: string[];
|
||||
|
||||
@OneToOne('user_profile', (profile: MiUserProfile) => profile.user)
|
||||
public userProfile: MiUserProfile | null;
|
||||
|
||||
constructor(data: Partial<MiUser>) {
|
||||
if (data == null) return;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export class MiUserProfile {
|
||||
@PrimaryColumn(id())
|
||||
public userId: MiUser['id'];
|
||||
|
||||
@OneToOne(type => MiUser, {
|
||||
@OneToOne(() => MiUser, user => user.userProfile, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn()
|
||||
|
||||
Reference in New Issue
Block a user