i have two entity
import {Entity, PrimaryGeneratedColumn, Column, ManyToOne} from "typeorm";
import {User} from "./User";
@Entity()
export class Photo {
@PrimaryGeneratedColumn()
id: number;
@Column()
url: string;
@ManyToOne(type => User, user => user.photos)
user: User;
}
import {Entity, PrimaryGeneratedColumn, Column, OneToMany} from "typeorm";
import {Photo} from "./Photo";
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@OneToMany(type => Photo, photo => photo.user)
photos: Photo[];
}
md5-2329ec9444f8cc468ce5f138eda9120d
return this.repo
.createQueryBuilder('user')
.leftJoinAndSelect('user.photos', 'photos')
.getMany();
md5-9b2f647b9bd680472e1094c328c3ced4
{
id:1,
name:'test',
photos:null
}
Is there any way I can get user data which phote data is null in typerom crud join?
thank you.
and you can do this for now
// @ts-ignore left join only
TypeOrmCrudService.prototype.getJoinType = function(s: string) {
return 'leftJoin';
};
@Diluka thank you
98 WIP
and you can do this for now
// @ts-ignore left join only TypeOrmCrudService.prototype.getJoinType = function(s: string) { return 'leftJoin'; };
Where should I put this code? In the service that extends TypeOrmCrudService?
@biammsilva anywhere before you actually use service. I suggest using it like a polyfill.
you can create a patch.ts file and import './patch' in the bootstrap file.
Most helpful comment
98 WIP
and you can do this for now