我有一个像波纹管这样的联接查询,我正在尝试将其转换为typeOrm查询
SELECT a.actionName
FROM walletAppActions wa
INNER JOIN actions a on a.actionId = wa.actionId
WHERE wa.appId = 1
ActionConfig.entity.ts
@Entity('actions')
export class WalletAppActionsEntity{
@PrimaryGeneratedColumn("increment")
actionId: number;
@Column()
actionName: string;
@OneToOne( type => Actions , config => config.action)
config: Actions;
}
appActions.entity.ts
@Entity('walletAppActions')
export class Actions{
@PrimaryGeneratedColumn("increment")
id: number;
@Column()
appId: number;
@Column()
actionId: number;
@OneToOne( type => WalletAppActionsEntity , action => action.config)
action: WalletAppActionsEntity;
}
表结构已附在此处
walletAppActions表
操作表
答案 0 :(得分:0)
尝试一下
let data=await getManager().getRepository(WalletAppActionsEntity)
.createQueryBuilder('wa')// where wa is alias
.leftJoinAndSelect('actions','acti','wa.id = :id',{id:1})//acti is alias
.getOne();