Webstorm live templates for TypeORM

Fast code generation shortcuts/live templates using with Webstorm/Phpstorm for TypeORM library.

  • TypeORM
  • Copy code to clipboard, then paste in Webstorm -> Settings -> Live templates
  • You need to decode the XML first in base64 decoder
<template name="+def" value="default: $value$" description="Column config property: default" toReformat="false" toShortenFQNames="true">
  <variable name="value" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="+un" value="unique: true" description="Column config property: unique" toReformat="false" toShortenFQNames="true">
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="boolcol" value="/**
 * $name$
 */
@Column('boolean')
public $name$: boolean;

$end$" description="@Column('boolean')" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="col" value="/**
 * $name$
 */
@Column($config$)
public $name$: $type$;

$end$" shortcut="TAB" description="@Column()" toReformat="false" toShortenFQNames="true">
  <variable name="config" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="type" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="dateccol" value="/**
 * created
 */
@Column({ nullable: false, default: () => 'CURRENT_TIMESTAMP' })
public created: Date;

$end$" description="@Column() created" toReformat="false" toShortenFQNames="true">
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="datecol" value="/**
 * $name$
 */
@Column()
public $name$: Date;

$end$" description="@Column() T: Date" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="dateucol" value="/**
 * lastModified
 */
@Column({ nullable: false, default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP' })
public lastModified: Date;

$end$" description="@Column() last_modified" toReformat="false" toShortenFQNames="true">
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="ent" value="import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';

/**
 * $name$
 */
@Entity()
export class $name$ {

    $end$

}
" description="new Entity" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="mtocol" value="/**
 * $name$
 */
@ManyToOne(type => $type$)
public $name$: Promise<$type$>;

$end$" shortcut="TAB" description="@ManyToOne()" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="type" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="nboolcol" value="/**
 * $name$
 */
@Column('boolean', { nullable: true })
public $name$: boolean;

$end$" description="Nullable @Column('boolean')" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="ncol" value="/**
 * $name$
 */
@Column({ nullable: true })
public $name$: $type$;

$end$" description="Nullable @Column()" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="type" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="ndatecol" value="/**
 * $name$
 */
@Column({ nullable: true })
public $name$: Date;

$end$" description="Nullable @Column() T: Date" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="nnumcol" value="/**
 * $name$
 */
@Column({ nullable: true })
public $name$: number;

$end$" description="Nullable @Column() T: Number" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="ntextcol" value="/**
 * $name$
 */
@Column('text', { nullable: true })
public $name$: string;

$end$" description="Nullable @Column('text')" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="ntintcol" value="/**
 * $name$
 */
@Column('tinyint', { nullable: true })
public $name$: number;

$end$" description="Nullable @Column('tinyint')" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="numcol" value="/**
 * $name$
 */
@Column()
public $name$: number;

$end$" description="@Column() T: Number" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="nvcol" value="/**
 * $name$
 */
@Column({ nullable: true, length: $length$ })
public $name$: string;

$end$" description="Nullable @Column() T: String" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="length" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="pcol" value="/**
 * $name$
 */
@PrimaryGeneratedColumn($config$)
public $name$: number;

$end$" description="@PrimaryGeneratedColumn()" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="config" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="textcol" value="/**
 * $name$
 */
@Column('text')
public $name$: string;

$end$" description="@Column('text')" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="tintcol" value="/**
 * $name$
 */
@Column('tinyint')
public $name$: number;

$end$" description="@Column('tinyint')" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>
<template name="vcol" value="/**
 * $name$
 */
@Column({ length: $length$ })
public $name$: string;

$end$" description="@Column() T: String" toReformat="false" toShortenFQNames="true">
  <variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="length" expression="" defaultValue="" alwaysStopAt="true" />
  <variable name="end" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="TypeScript" value="true" />
  </context>
</template>

Leave a Reply

Your email address will not be published. Required fields are marked *