i have this entity file:
@Entity('post-comments')
export class PostComment extends Base {
@Index()
@Column('uuid')
commented_by_id: string;
@Column('varchar', { length: postCommentContentMaxLength })
content: string;
@Index()
@Column('uuid')
post_id: string;
@Index()
@Column('uuid', { nullable: true, default: null })
parent_id: NullableValue<string>;
@ManyToOne(() => User, (user) => user.posts)
@JoinColumn({ name: 'commented_by_id' })
commented_by: User;
@ManyToOne(() => Post, (post) => post)
@JoinColumn({ name: 'post_id' })
post: Post;
}
export const alias = 'post-comment';
export const commented_by_alias = 'commented_by';
export type PostCommentSelectKey =
| `${typeof alias}.${keyof PostComment}`
| `${typeof commented_by_alias}.${keyof User}`;
export const base_select_fields = [
'post-comment.id',
'post-comment.content',
'post-comment.created_at',
'post-comment.updated_at',
'post-comment.parent_id',
'post-comment.post_id',
'commented_by.id',
'commented_by.user_photo_url',
'commented_by.user_name',
] satisfies PostCommentSelectKey[];
And i want to create a type that does this:
const test: EntityFromAliasArray<'post-comment', PostComment, typeof base_select_fields> = {
id: string;
content: string
created_at: string
updated_at?: string
parent_id: string | null;
commented_by: {
id: string;
user_photo_url: string | null;
user_name: string
}
}
Is that possible ?