JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 65
  • Score
    100M100P100Q69535F
  • License ISC

typeorm commonly used extensions

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (typeorm-extensions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    TypeORM Extensions

    Build Status npm version

    Description

    TypeORM Extensions is a library that provides additional functionality and extensions for the TypeORM QueryBuilder. It aims to simplify common tasks and enhance the capabilities of TypeORM.

    Features

    • Simplicity: applying pagination and ordering to queries is as simple as calling a method.
    • Type Safety: the library is written in TypeScript and provides type-safe QueryBuilder methods based on Entity metadata.
    • Flexibility: the library is designed to be flexible and can be used with any TypeORM entity.

    Installation

    To install typeorm-extensions:

    Install using npm, yarn or pnpm:

    npm install typeorm-extensions

    Usage

    import 'typeorm-extensions'; // Import the library root to extend the QueryBuilder with all extensions
    
    // Or init specific extension: import from 'typeorm-extensions/dist/extensions/pagination.extension';
    
    const query = myDataSource
      .createQueryBuilder()
      .from(UserEntity, 'users')
      // Join relation defined in entity model
      .leftJoinTyped(user => users.profile, 'profile')
      // Select type-safe properties
      .selectTyped(user => ([
        id: user.id,
        name: user.name,
        email: user.email,
      ]))
      .whereTyped(user => user.name, 'ILIKE :search', { search: 'John' })
      // Order by type-safe own and relation properties
      .orderByTyped(user => user.profile.avatarUrl, 'ASC', 'NULLS LAST')
      // Use pagination as simple as that
      .applyPaginationFilter({ page: 1, pageSize: 10 }, { useTakeAndSkip: true });

    Documentation

    For more information, please refer to the documentation.