如何在棱柱模式中以两个可能的this.todo = ''
为目标来创建NavigationView nvDrawer;
Menu menu = nvDrawer.getMenu();
for (int i = 0; i < menu.size(); i ++){
MenuItem menuItem = menu.getItem(i);
if (menuItem.getTitle().equals("Logout")){
SpannableString spanString = new SpannableString(menuItem.getTitle().toString());
spanString.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.red)), 0, spanString.length(), 0);
menuItem.setTitle(spanString);
}
}
?
例如,在足球比赛中,我们有以下两种型号:
relation field
在relation scalar fields
关系字段定义中要放置什么,以允许model Match {
team1Id Int
team1 Team @relation("team1", fields: [team1Id], references: [id])
team2Id Int
team2 Team @relation("team2", fields: [team2Id], references: [id])
}
model Team {
id Int @default(autoincrement()) @id
name String
matches Match[] @relation( /* What to put here ? */ ) // <----
}
包含团队从任一方进行的任何比赛,例如team1或team2?
答案 0 :(得分:2)
目前在Prisma中这是不可能的!我在repo for technical specifications中创建了一个问题,以考虑改善此问题的方法!
解决方法
使用Prisma,您始终需要在每个关系的两边都有一个关系字段。这意味着您需要在Team
上有两个关系字段,一个代表团队“以第1队”的比赛,另一个代表“以第2队”的比赛。
model Match {
team1Id Int
team1 Team @relation("team1", fields: [team1Id], references: [id])
team2Id Int
team2 Team @relation("team2", fields: [team2Id], references: [id])
@@id([team1Id, team2Id])
}
model Team {
id Int @default(autoincrement()) @id
name String
matchesAsTeam1 Match[] @relation("team1")
matchesAsTeam2 Match[] @relation("team2")
}