0.3.1 • Published 1 year ago

@esnark/typeorm-mapped-types v0.3.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

typeorm-mapped-types presents a new way to manage TypeORM entities. You can prototype entities that reflect actual database tables and create new entities appropriate for your domain as needed.

This module is based on @nestjs/mapped-types. However, unlike @nestjs/mapped-types, it does not support @nestjs/swagger but only the typeorm decorator. Future versions may include support for @nestjs/swagger.

Available mapped types:

  • PickType - constructs a new type (class) by picking a set of properties from an input type
  • OmitType - constructs a type by picking all properties from an input type and then removing a particular set of keys
  • IntersectionType - (Not implemented) combines two types into one new type

How to use

import { Entity, PrimaryColumn, Column } from 'typeorm';

export class UserModel {
  @PrimaryColumn()
  id: number;

  @Column()
  email: string;

  /** no need for most cases */
  @Column()
  privacyData: string;
}
import { PickType } from '@esnark/typeorm-mapped-types';
import { UserModel } from './user-model';

@Entity('user')
export class QueriedUser extends PickType(UserModel, ['id', 'email'] as const) {}
0.3.1

1 year ago

0.3.1-alpha

1 year ago

0.3.0-alpha

1 year ago

0.2.0

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.1.0-alpha.1

1 year ago

0.1.0-alpha.0

1 year ago