How to use the typeorm.PrimaryColumn function in typeorm

To help you get started, we’ve selected a few typeorm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitwit / typescript-express-api-template / api / models / entities / AuthToken.ts View on Github external
import { Entity, BaseEntity, PrimaryGeneratedColumn, Column, PrimaryColumn, OneToOne, JoinColumn } from "typeorm"
import { User } from "./User"
import * as uuid from 'uuid'

@Entity()
class AuthToken extends BaseEntity {

  @PrimaryColumn("uuid")
  token: string

  @Column({ default: () => "(CURRENT_TIMESTAMP + interval '3' day)" })
  expiry: Date

  @PrimaryColumn("uuid")
  refreshToken: string

  @Column({ default: () => "(CURRENT_TIMESTAMP + interval '30' day)" })
  refreshExpiry: Date

  @OneToOne(type => User, { nullable: false })
  @JoinColumn()
  user: User

  public constructor() {
github new-eden-social / new-eden-social / src / services / hashtag / hashtag.entity.ts View on Github external
import { Entity, PrimaryColumn } from 'typeorm';

@Entity()
export class Hashtag {

  @PrimaryColumn('text')
  name: string;

  constructor(name: string) {
    this.name = name;
  }

}
github vendure-ecommerce / vendure / server / src / plugin / default-search-plugin / search-index-item.entity.ts View on Github external
import { idType } from '../../config/config-helpers';

@Entity()
export class SearchIndexItem {
    constructor(input?: Partial) {
        if (input) {
            for (const [key, value] of Object.entries(input)) {
                this[key] = value;
            }
        }
    }

    @PrimaryColumn({ type: idType() })
    productVariantId: ID;

    @PrimaryColumn('varchar')
    languageCode: LanguageCode;

    @Column({ type: idType() })
    productId: ID;

    @Index({ fulltext: true })
    @Column()
    productName: string;

    @Index({ fulltext: true })
    @Column()
    productVariantName: string;

    @Index({ fulltext: true })
    @Column('text')
    description: string;
github alitelabs / tyx / src / orm / decorators.ts View on Github external
export function PrimaryIdColumn(options?: ColumnOptions) {
    let op: ColumnOptions = { type: "varchar", length: 36 };
    Object.assign(op, options || {});
    return PrimaryColumn(op);
}
github wix / quix / quix-frontend / service / src / entities / dbnotebook.entity.ts View on Github external
PrimaryColumn,
  OneToMany,
  OneToOne,
  BeforeInsert,
  BeforeUpdate,
  UpdateDateColumn,
  CreateDateColumn,
} from 'typeorm';
import {DbNote} from './dbnote.entity';
import {DbFileTreeNode} from './filenode.entity';
import {INote, IFilePathItem, INotebook} from 'shared';
import {dbConf} from '../config/db-conf';

@Entity({name: 'notebooks'})
export class DbNotebook implements INotebook {
  @PrimaryColumn(dbConf.idColumn)
  id!: string;

  @Column(dbConf.shortTextField)
  name!: string;

  @Column(dbConf.shortTextField)
  owner!: string;

  @UpdateDateColumn(dbConf.dateUpdated)
  dateUpdated!: number;

  @CreateDateColumn(dbConf.dateCreated)
  dateCreated!: number;

  @Column({...dbConf.json, name: 'json_content'})
  jsonContent: any = {};
github vendure-ecommerce / vendure / packages / core / src / plugin / default-search-plugin / search-index-item.entity.ts View on Github external
import { EntityId } from '../../entity/entity-id.decorator';

@Entity()
export class SearchIndexItem {
    constructor(input?: Partial) {
        if (input) {
            for (const [key, value] of Object.entries(input)) {
                (this as any)[key] = value;
            }
        }
    }

    @EntityId({ primary: true })
    productVariantId: ID;

    @PrimaryColumn('varchar')
    languageCode: LanguageCode;

    @EntityId()
    productId: ID;

    @Column()
    enabled: boolean;

    @Index({ fulltext: true })
    @Column()
    productName: string;

    @Index({ fulltext: true })
    @Column()
    productVariantName: string;
github benawad / codeponder / packages / server / src / entity / CommentMentionNotification.ts View on Github external
JoinColumn,
  ManyToOne,
  PrimaryColumn,
  UpdateDateColumn,
} from "typeorm";
import { Comment } from "./Comment";
import { User } from "./User";

@Entity()
@ObjectType()
export class CommentMentionNotification {
  @Field(() => Comment)
  @ManyToOne(() => Comment, { onDelete: "CASCADE" })
  comment: Promise;
  @Field()
  @PrimaryColumn("uuid")
  commentId: string;

  @ManyToOne(() => User, { onDelete: "CASCADE" })
  @JoinColumn({ name: "userMentionedId" })
  userMentioned: Promise;
  @Field()
  @Column("uuid")
  userMentionedId: string;

  @Field()
  @Column()
  read: boolean;

  @Field()
  @CreateDateColumn({ type: "timestamp with time zone" })
  createdAt: Date;
github bkinsey808 / graphql-fullstack-seed / server / src / entity / AppUser.ts View on Github external
],
  mutations: [
    getCreateQuery,
    getDeleteQuery,
    getUpdateQuery
  ]
})
@Entity()
export class AppUser {

  @ColumnApi({
    apiName: 'id',
    apiType: 'Int',
    apiDescription: 'unique identifier'
  })
  @PrimaryColumn('int', { generated: true })
  id: number;

  @ColumnApi({
   apiName: 'firstName',
   apiType: 'String',
   apiDescription: 'the first name',
   updatable: true,
   requiredForCreate: true
  })
  @Column('string', { nullable: true })
  firstName: string;

  @ColumnApi({
   apiName: 'lastName',
   apiType: 'String',
   apiDescription: 'the last name',
github new-eden-social / new-eden-social / src / services / corporation / corporation.entity.ts View on Github external
import {
  Column,
  Entity,
  PrimaryColumn,
  UpdateDateColumn,
} from 'typeorm';
import { IGetCorporation } from '@new-eden-social/esi';
import { ICorporationIcon } from './corporation.interface';

@Entity()
export class Corporation {

  @PrimaryColumn('int')
  id: number;

  @Column({ unique: true })
  handle: string;

  @Column()
  name: string;

  @Column()
  ticker: string;

  @Column('text')
  description: string;

  @Column()
  ceoId?: number;