Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeorm query spesific selecion #10853

Open
1 of 18 tasks
lakmal05 opened this issue Apr 25, 2024 · 1 comment
Open
1 of 18 tasks

typeorm query spesific selecion #10853

lakmal05 opened this issue Apr 25, 2024 · 1 comment

Comments

@lakmal05
Copy link

Issue description

Issue

Expected Behavior

there is no any mention about the spesific selection

Actual Behavior

there is no any mention about the spesific selection

Steps to reproduce

there is no any mention about the spesific selection

My Environment

Dependency Version
Operating System
Node.js version x.y.zzz
Typescript version x.y.zzz
TypeORM version x.y.zzz

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

@iJhefe
Copy link
Contributor

iJhefe commented Apr 25, 2024

if you are using Repository, you can pass the param "select" in find/findOne, for example:

// you can use with find, findOne, findOneOrFail
repository.find({
  select: {
    id: true,
    role: {
      id: true,
      name: true,
    }
  },
  relations: {
    role: true,
  },
  where: {
    id: In([1, 2, 3]),
  }
});

and with QueryBuilder

manager.createQueryBuilder(User, 'user')
  .select('user.id')
  .addSelect('role.id')
  .addSelect('role.name')
  .innerJoin('user.role', 'role')
  .where('user.id IN (:...ids)', { ids: [1, 2, 3] })
  .getMany();

see https://typeorm.io/find-options, https://typeorm.io/select-query-builder, https://typeorm.io/select-query-builder#partial-selection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants