本周我尝试加入Apple开发者计划.没有它,我无法向商店发布应用程序.
在注册程序中输入 https://developer.apple.com/programs/enroll
它要求我打开双因素身份验证.我这样做了,插入了我的电话号码,现在我每次登录时都需要输入密码并将我的4位数发送到手机上.
在我再次进入注册程序后,再次显示设置双因素身份验证的免责声明.
谁有同样的问题?
我试图弄清楚如何创建一个用户实体,该实体与包含其他用户实体的朋友列上的关系。通过 userId 对的联接表进行联接。这种作品:
@Entity('user')
export class User {
@PrimaryGeneratedColumn('uuid')
id: string;
@ManyToMany(
() => User,
(user) => user.friends
)
@JoinTable()
friends: User[];
}
Run Code Online (Sandbox Code Playgroud)
它确实创建了一个关系,我可以用 id 填充连接表并检索数据,但这似乎只是一种方法。
这是连接表:
userId_1 | userId_2
------------+------------
Run Code Online (Sandbox Code Playgroud)
我所说的一种方式是指链接似乎来自 userId_1 -> userId_2 而不是两种方式。对此有什么办法可以改进吗?我希望能够根据单行条目从任一侧获取关系
如果你有需要在渲染时运行的函数并且必须传递变量,那么在本机做出反应时,大多数人建议应该使用
onPress{() => this.functionName(variable)}
Run Code Online (Sandbox Code Playgroud)
但是,在处理大型列表和复杂组件时,您必须优化代码.为每个renderItem创建一个新函数可以flatList降低性能,有时甚至会很大,具体取决于您创建的每个renderItem的函数数量.所以建议从创建渲染函数到使用函数引用.像这样:
functionName = () => {
//code
}
onPress={this.functionName}
Run Code Online (Sandbox Code Playgroud)
但是我无法弄清楚如何使用此方法将变量传递给函数.
如果你这样做:
onPress={this.functionName(variable}
Run Code Online (Sandbox Code Playgroud)
它只会在组件负载上立即运行该功能.
有任何想法吗?
因为我不想使用级联来更新连接表并且我想要自定义列,所以我创建了一个自定义的多对多关系。但是,当我查询关系时,它仅提供连接表中的值,而不提取关系数据。
用户
@Entity('user')
export class User {
@PrimaryColumn()
id: string;
@OneToMany(
() => UserArtistFollowing,
(userArtistFollowing) => userArtistFollowing.user
)
following: UserArtistFollowing[];
}
Run Code Online (Sandbox Code Playgroud)
艺术家
@Entity('artist')
export class Artist {
@PrimaryGeneratedColumn('uuid')
id: string;
@OneToMany(
() => UserArtistFollowing,
(userArtistFollowing) => userArtistFollowing.artist
)
usersFollowing: UserArtistFollowing[];
}
Run Code Online (Sandbox Code Playgroud)
用户艺术家正在关注
@Entity('userArtistFollowing')
export class UserArtistFollowing {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column()
userId!: string;
@Column()
artistId!: string;
@ManyToOne(
() => User,
(user) => user.following
)
user!: User;
@ManyToOne(
() => Artist,
(artist) => artist.usersFollowing
)
artist!: Artist;
@CreateDateColumn()
createdAt!: Date;
@UpdateDateColumn() …Run Code Online (Sandbox Code Playgroud)