Skip to main content

selectTyped

Description

selectTyped is a method that applies typesafe select to a query.

Signature

selectTyped(
selection: KeyProxyCallback<Entity>,
alias?: string
): SelectQueryBuilder<Entity>

Arguments

  • selection: KeyProxyCallback<Entity>: The callback which selects fields of entity.
  • alias?: string: Alias for the selection

Usage

// same as `query.select('user.name', 'fullName')`
query.selectTyped(user => user.name, 'fullName')
// same as `query.select(['id', 'name'])`
query.selectTyped(user => [
user.id,
user.name,
])
// same as `query.addSelect('user.createdAt', 'registeredAt')`
query.addSelectTyped(user => user.createdAt, 'registeredAt')