TypeORM-readme-48.ts
· 527 B · TypeScript
Sin formato
const photos = await AppDataSource.getRepository(Photo)
.createQueryBuilder("photo") // first argument is an alias. Alias is what you are selecting - photos. You must specify it.
.innerJoinAndSelect("photo.metadata", "metadata")
.leftJoinAndSelect("photo.albums", "album")
.where("photo.isPublished = true")
.andWhere("(photo.name = :photoName OR photo.name = :bearName)")
.orderBy("photo.id", "DESC")
.skip(5)
.take(10)
.setParameters({ photoName: "My", bearName: "Mishka" })
.getMany()
1 | const photos = await AppDataSource.getRepository(Photo) |
2 | .createQueryBuilder("photo") // first argument is an alias. Alias is what you are selecting - photos. You must specify it. |
3 | .innerJoinAndSelect("photo.metadata", "metadata") |
4 | .leftJoinAndSelect("photo.albums", "album") |
5 | .where("photo.isPublished = true") |
6 | .andWhere("(photo.name = :photoName OR photo.name = :bearName)") |
7 | .orderBy("photo.id", "DESC") |
8 | .skip(5) |
9 | .take(10) |
10 | .setParameters({ photoName: "My", bearName: "Mishka" }) |
11 | .getMany() |