typeorm#BaseEntity TypeScript Examples

The following examples show how to use typeorm#BaseEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: guestRequest.ts    From Corsace with MIT License 6 votes vote down vote up
@Entity()
export class GuestRequest extends BaseEntity {

    @PrimaryGeneratedColumn()
    ID!: number;

    @ManyToOne(() => MCA, {
        nullable: false,
        eager: true,
    })
    mca!: MCA;

    @ManyToOne(() => ModeDivision, modeDivision => modeDivision.guestRequests, {
        nullable: false,
        eager: true,
    })
    mode!: ModeDivision;

    @Column({ type: "enum", enum: RequestStatus, default: RequestStatus.Pending })
    status!: RequestStatus

    @ManyToOne(() => User, user => user.guestRequests, {
        nullable: false,
    })
    user!: User;

    @ManyToOne(() => Beatmap, beatmap => beatmap.guestRequests, {
        nullable: false,
        eager: true,
    })
    @JoinTable()
    beatmap!: Beatmap;

}
Example #2
Source File: entity-meta.ts    From Cromwell with MIT License 6 votes vote down vote up
getMetaClass(entityType: EDBEntity): (new (...args: any[]) => TEntityMetaModel) & typeof BaseEntity | undefined {
        if (entityType === EDBEntity.Attribute) return AttributeMeta;
        if (entityType === EDBEntity.Order) return OrderMeta;
        if (entityType === EDBEntity.Post) return PostMeta;
        if (entityType === EDBEntity.ProductCategory) return ProductCategoryMeta;
        if (entityType === EDBEntity.Product) return ProductMeta;
        if (entityType === EDBEntity.Tag) return TagMeta;
        if (entityType === EDBEntity.User) return UserMeta;
        if (entityType === EDBEntity.CustomEntity) return CustomEntityMeta;
        if (entityType === EDBEntity.Coupon) return CouponMeta;
        if (entityType === EDBEntity.ProductVariant) return ProductVariantMeta;
    }
Example #3
Source File: cart-item.ts    From nodeJS-express-postgresql with MIT License 6 votes vote down vote up
@Entity()
export class CartItem extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column('smallint', { nullable: false })
  quantity: number;

  @ManyToOne(() => Cart, cart => cart.cItem, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
  @JoinColumn({ name: 'cartid' })
  cartid: Cart;

  @ManyToOne(() => Product, prod => prod.cItem, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
  @JoinColumn({ name: 'productid' })
  prodid: Product;
}
Example #4
Source File: ModelBase.ts    From barista with Apache License 2.0 6 votes vote down vote up
export class ModelBase extends BaseEntity {
  @ApiProperty()
  @CreateDateColumn({ name: 'created_at', nullable: false })
  createdAt: Date;

  @ApiProperty()
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty()
  @Column({ type: 'jsonb', nullable: true })
  metaData: any;

  @ApiProperty()
  @Column({ nullable: true })
  tag: string;

  @ApiProperty()
  @UpdateDateColumn({ name: 'updated_at', nullable: true })
  updatedAt: Date;
}
Example #5
Source File: Auditable.ts    From Full-Stack-React-TypeScript-and-Node with MIT License 6 votes vote down vote up
export class Auditable extends BaseEntity {
  @Column("varchar", {
    name: "CreatedBy",
    length: 60,
    default: () => `getpgusername()`,
    nullable: false,
  })
  createdBy: string;

  @Column("timestamp with time zone", {
    name: "CreatedOn",
    default: () => `now()`,
    nullable: false,
  })
  createdOn: Date;

  @Column("varchar", {
    name: "LastModifiedBy",
    length: 60,
    default: () => `getpgusername()`,
    nullable: false,
  })
  lastModifiedBy: string;

  @Column("timestamp with time zone", {
    name: "LastModifiedOn",
    default: () => `now()`,
    nullable: false,
  })
  lastModifiedOn: Date;
}
Example #6
Source File: JtiLog.ts    From ADR-Gateway with MIT License 6 votes vote down vote up
@Entity()
class JtiLog extends BaseEntity {
    @PrimaryGeneratedColumn()
    id!: number;
    @Column()
    jti!: string;
    @Column()
    iss!: string;
    @Column()
    sub!: string;
}
Example #7
Source File: custom.entity.ts    From adminjs-upload with MIT License 6 votes vote down vote up
@Entity({ name: 'custom' })
export class Custom extends BaseEntity {
  @PrimaryGeneratedColumn()
  public id: number;

  @Column({ nullable: true })
  public filePath: string;

  @Column({ nullable: true })
  public bucket: string;

  @CreateDateColumn()
  public createdAt: Date;

  @UpdateDateColumn()
  public updatedAt: Date;
}
Example #8
Source File: option.entity.ts    From nest-js-quiz-manager with MIT License 6 votes vote down vote up
@Entity('options')
export class Option extends BaseEntity {
  @ApiProperty({ description: 'Primary key as Option ID', example: 1 })
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ description: 'The actual option', example: 'Owl' })
  @Column({
    type: 'varchar',
  })
  text: string;

  @ApiProperty({ description: 'Whether option is correct', example: true })
  @Column({
    type: 'boolean',
  })
  isCorrect: boolean;

  @ManyToOne(() => Question, (question) => question.options)
  question: Question;
}
Example #9
Source File: branch.entity.ts    From typeorm-query-builder-wrapper with MIT License 6 votes vote down vote up
@Entity('ptc_branch')
export class Branch extends BaseEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'boolean', name: 'is_deleted', default: false })
  isDeleted: boolean;

  @Column({ type: 'uuid', name: 'user_id', nullable: false })
  userId: string;

  @CreateDateColumn({
    type: 'timestamp',
    name: 'create_date_time',
  })
  createDateTime: Date;

  @Column('character varying', {
    nullable: false,
    length: 255,
    name: 'branch_name',
  })
  branchName: string;

  @Column('numeric', {
    nullable: false,
    name: 'branch_code',
  })
  branchCode: number;

  @OneToOne(() => User)
  @JoinColumn({ name: 'user_id', referencedColumnName: 'id' })
  user: User;
}
Example #10
Source File: posts.entity.ts    From awsmug-serverless-graphql-api with MIT License 6 votes vote down vote up
@Entity()
export class Posts extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  title: string;

  @Column()
  text: string;
}
Example #11
Source File: Updoot.ts    From lireddit with MIT License 6 votes vote down vote up
// m to n
// many to many
// user <-> posts
// user -> join table <- posts
// user -> updoot <- posts

@Entity()
export class Updoot extends BaseEntity {
  @Column({ type: "int" })
  value: number;

  @PrimaryColumn()
  userId: number;

  @ManyToOne(() => User, (user) => user.updoots)
  user: User;

  @PrimaryColumn()
  postId: number;

  @ManyToOne(() => Post, (post) => post.updoots, {
    onDelete: "CASCADE",
  })
  post: Post;
}
Example #12
Source File: Feed.ts    From vsinder with Apache License 2.0 6 votes vote down vote up
@Entity()
export class Feed extends BaseEntity {
  @PrimaryGeneratedColumn("uuid")
  id: string;

  @Column("int", { nullable: true })
  cursor: number;

  @Column("text", { array: true })
  userIds: string[];

  @Column()
  ownerId: number;

  @OneToOne(() => User, {
    primary: true,
    onDelete: "CASCADE",
  })
  @JoinColumn({ name: "ownerId" })
  owner: Promise<User>;
}
Example #13
Source File: View.ts    From vsinder-api with Apache License 2.0 6 votes vote down vote up
@Entity()
export class View extends BaseEntity {
  @PrimaryColumn()
  viewerId: string;

  @PrimaryColumn()
  targetId: string;

  @ManyToOne(() => User, (u) => u.views, {
    primary: true,
    onDelete: "CASCADE",
  })
  @JoinColumn({ name: "viewerId" })
  viewer: Promise<User>;

  @ManyToOne(() => User, (u) => u.targets, {
    primary: true,
    onDelete: "CASCADE",
  })
  @JoinColumn({ name: "targetId" })
  target: Promise<User>;

  @Column("boolean")
  liked: boolean;
}
Example #14
Source File: ChatCategory.entity.ts    From bouncecode-cms with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 관리자가 지정하는 채팅 룸의 종류입니다.
 *
 * @author BounceCode, Inc.
 */
@Entity()
export class ChatCategoryEntity extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  title: string;

  @Column()
  description: string;

  @OneToMany(
    () => ChatRoomEntity,
    room => room.category,
    {cascade: false, onDelete: 'SET NULL'},
  )
  rooms: ChatRoomEntity[];

  @Column('json')
  payload: any;

  @VersionColumn()
  version: number;

  @CreateDateColumn()
  createdDate: Date;

  @UpdateDateColumn()
  updatedDate: Date;

  @DeleteDateColumn()
  deletedDate: Date;
}
Example #15
Source File: UserAccount.ts    From Wern-Fullstack-Template with MIT License 6 votes vote down vote up
@ObjectType()
@Entity()
export class UserAccount extends BaseEntity {
  @Field()
  @PrimaryGeneratedColumn()
  id!: number

  @Field()
  @Column({ unique: true })
  username!: string

  @Field()
  @Column({ unique: true })
  email!: string

  @Column()
  password!: string

  @Field(() => String)
  @CreateDateColumn()
  createdAt: Date

  @Field(() => String)
  @UpdateDateColumn()
  updatedAt: Date
}
Example #16
Source File: api-key.ts    From crossfeed with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@Entity()
export class ApiKey extends BaseEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;

  @ManyToOne((type) => User, (user) => user.apiKeys, {
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE'
  })
  user: User;

  @Column({
    type: 'timestamp',
    nullable: true
  })
  lastUsed: Date | null;

  @Column({
    type: 'text'
  })
  hashedKey: string;

  @Column({
    type: 'text'
  })
  lastFour: string;
}
Example #17
Source File: NoSqlBase.ts    From confidential-storage with Apache License 2.0 6 votes vote down vote up
@Entity()
export class Base extends BaseEntity {
  @ObjectIdColumn()
  id!: string;

  @ObjectIdColumn({ name: 'id' })
  _id!: string;

  @BeforeInsert()
  public async validate() {
    // TODO: here we could assign IDs by content

    // docs and indexes have id set by client.
    if (!this._id && !this.id) {
      this._id = await EdvClient.generateId();
    } else {
      // special ids for docs
      this._id = this.id;
    }
  }
}
Example #18
Source File: request.ts    From opensaas with MIT License 6 votes vote down vote up
@Directive('@key(fields: "id")')
@Entity({ name: 'requests' })
@ObjectType()
export class Request extends BaseEntity {
  @Field(() => ID)
  @PrimaryGeneratedColumn()
  id!: number;

  @Field(() => ID)
  @Column('varchar', { length: 256, nullable: false })
  tenantId!: string;

  @Field(() => String)
  @Column('text', { nullable: false })
  url!: string;

  @Field(() => Number)
  @Column('smallint', { nullable: false })
  statusCode!: number;

  @Field(() => String)
  @Column('text', { nullable: false })
  userAgent!: string;

  @Field(() => String)
  @Column('varchar', { length: 32 })
  ip!: string;

  @Field(() => Date)
  @CreateDateColumn({ type: 'timestamp' })
  createdAt!: Date;

  @Field(() => Date)
  @UpdateDateColumn({ type: 'timestamp' })
  updatedAt!: Date;
}
Example #19
Source File: user.ts    From backend-postgres-typescript-node-express with MIT License 6 votes vote down vote up
@Entity(`${config.DB.MAIN_SCHEMA}.users`)
export class User extends BaseEntity {
  @PrimaryGeneratedColumn()
  public id: string

  @Column('varchar')
  public email: string

  @Column('timestamp with time zone')
  public created_at: Timestamp

  @Column('timestamp with time zone')
  public updated_at: Timestamp

  @Column('timestamp with time zone')
  public deleted_at: Timestamp
}
Example #20
Source File: MainEntity.ts    From liferay-grow with MIT License 6 votes vote down vote up
@ObjectType()
export class MainEntity extends BaseEntity {
  @Field(() => ID)
  @PrimaryColumn({ generated: 'uuid' })
  id: string;

  @Field()
  @CreateDateColumn()
  createdAt: Date;

  @Field()
  @UpdateDateColumn()
  updatedAt: Date;
}
Example #21
Source File: admin-user.entity.ts    From office-hours with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Admin users are totally separate from regular users and can only be created from command line.
 * `yarn cli admin:create`
 */
@Entity('admin_user_model')
export class AdminUserModel extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  setPassword(password: string): void {
    this.passwordHash = hashSync(password, 5);
  }

  @Column({ length: 128, unique: true, nullable: false })
  username: string;

  @Column({ length: 128, nullable: false })
  passwordHash: string;
}
Example #22
Source File: core.entity.ts    From nodejs-angular-typescript-boilerplate with Apache License 2.0 6 votes vote down vote up
export class CoreEntity extends BaseEntity {
    @PrimaryGeneratedColumn({type: "bigint"})
    id: number;
    
    @CreateDateColumn()
    createdAt: Date;

    @UpdateDateColumn()
    updatedAt: Date;
}
Example #23
Source File: model.ts    From WiLearning with GNU Affero General Public License v3.0 6 votes vote down vote up
@Entity()
export class ClaRoom extends BaseEntity{
    @PrimaryColumn()
    id: string;

    @Column()
    name: string;

    @Column()
    speakerPassword: string;

    @Column()
    attendeePassword: string;

    @Column("text")
    description: string;

    @Column()
    createTime: string;

    @Column()
    lastActiveTime: string;
}
Example #24
Source File: category.ts    From Corsace with MIT License 5 votes vote down vote up
@Entity()
export class Category extends BaseEntity {
    
    @PrimaryGeneratedColumn()
    ID!: number;

    @Column()
    name!: string;
    
    @Column()
    maxNominations!: number;

    @Column(() => CategoryFilter)
    filter?: CategoryFilter;

    @Column({ type: "enum", enum: CategoryType, default: CategoryType.Beatmapsets })
    type!: CategoryType;
    
    @ManyToOne(() => ModeDivision, modeDivision => modeDivision.categories, {
        nullable: false,
        eager: true,
    })
    mode!: ModeDivision;

    @ManyToOne(() => MCA, mca => mca.categories, {
        nullable: false,
        eager: true,
    })
    mca!: MCA;

    @OneToMany(() => Nomination, nomination => nomination.category)
    nominations!: Nomination[];
    
    @OneToMany(() => Vote, vote => vote.category)
    votes!: Vote[];

    public getInfo = function(this: Category): CategoryInfo {
        return {
            id: this.ID,
            name: this.name,
            maxNominations: this.maxNominations,
            type: CategoryType[this.type],
            mode: this.mode.name,
            isFiltered: this.filter && (this.filter.minLength || this.filter.maxLength || this.filter.minBPM || this.filter.maxBPM || this.filter.minSR || this.filter.maxSR || this.filter.minCS || this.filter.maxCS || this.filter.topOnly) ? true : false,
            filter: this.filter ?? undefined, 
        };
    }

    public getCondensedInfo = function(this: Category): CategoryCondensedInfo {
        return {
            name: this.name,
            type: CategoryType[this.type],
            mode: this.mode.name,
        };
    }

    public setFilter = function(this: Category, params?: CategoryFilter): void {
        if (!params)
            return;

        const filter = new CategoryFilter;
        filter.minLength = params.minLength ?? undefined;
        filter.maxLength = params.maxLength ?? undefined;
        filter.minBPM = params.minBPM ?? undefined;
        filter.maxBPM = params.maxBPM ?? undefined;
        filter.minSR = params.minSR ?? undefined;
        filter.maxSR = params.maxSR ?? undefined;
        filter.minCS = params.minCS ?? undefined;
        filter.maxCS = params.maxCS ?? undefined;
        filter.topOnly = params.topOnly ?? undefined;
        filter.rookie = params.rookie ?? undefined;
        this.filter = filter;
    }
}
Example #25
Source File: attribute-product.entity.ts    From Cromwell with MIT License 5 votes vote down vote up
@Entity()
@ObjectType()
export class AttributeToProduct extends BaseEntity {

    @Field(() => Int)
    @PrimaryGeneratedColumn()
    id: number;

    @Field(type => Int, { nullable: true })
    @Column("int", { nullable: true })
    @Index()
    productId: number;

    @ManyToOne(() => Product, product => product.attributeValues, {
        onDelete: "CASCADE"
    })
    @JoinColumn({ name: "productId" })
    product?: Product;

    @Field(type => Int, { nullable: true })
    @Column("int", { nullable: true })
    @Index()
    attributeValueId: number;

    @ManyToOne(() => AttributeValue, attribute => attribute.attributeToProduct, {
        onDelete: "CASCADE"
    })
    @JoinColumn({ name: "attributeValueId" })
    attributeValue?: AttributeValue;

    @Field(type => String)
    @Column({ type: "varchar", length: 255 })
    @Index()
    key: string;

    @Field(type => String)
    @Column({ type: "varchar", length: 255, nullable: true })
    @Index()
    value: string;
}
Example #26
Source File: DataHolderRegistration.ts    From ADR-Gateway with MIT License 5 votes vote down vote up
@Entity({name: 'AdrDataHolderRegistration'})
class DataHolderRegistration extends BaseEntity {
    @PrimaryGeneratedColumn()
    id!: number;

    @Column()
    softwareProductId!: string;

    @Column()
    dataholderBrandId!: string;

    @Column()
    clientId!: string;

    @Column({
        type: "simple-enum",
        enum: RegistrationStatus,
        default: RegistrationStatus.CURRENT
    })
    status!: RegistrationStatus;

    @Column()
    redirectUrlsJson!: string;

    @Column()
    scopesJson!: string;

    redirectUrls = () => {
        return JSON.parse(this.redirectUrlsJson);
    }

    scopes = () => {
        return JSON.parse(this.scopesJson);
    }

    // @Column()
    // logo_uri!: string;
    // @Column()
    // tos_uri!: string;
    // @Column()
    // policy_uri!: string;
    // @Column()
    // jwks_uri!: string;
    // @Column()
    // revocation_uri!: string;

    @Column()
    lastUpdated!: Date;

    @Column()
    issuedAt!: Date;

}
Example #27
Source File: quiz.entity.ts    From nest-js-quiz-manager with MIT License 5 votes vote down vote up
@Entity('quizes')
export class Quiz extends BaseEntity {
  @ApiProperty({ description: 'Primary key as Quiz ID', example: 1 })
  @PrimaryGeneratedColumn({
    comment: 'The quiz unique identifier',
  })
  id: number;

  @ApiProperty({
    description: 'Title of the quiz',
    example: 'Sample Laravel quiz',
  })
  @Column({
    type: 'varchar',
  })
  title: string;

  @ApiProperty({
    description: 'Description of the quiz',
    example: 'Lorem ipsum',
  })
  @Column({
    type: 'text',
  })
  description: string;

  @ApiProperty({
    description: 'Quiz active or inactive state',
    example: true,
  })
  @Column({
    type: 'boolean',
    default: 1,
  })
  isActive: boolean;

  @ApiProperty({
    description: 'List of questions',
  })
  @OneToMany(() => Question, (question) => question.quiz)
  questions: Question[];
}
Example #28
Source File: user.entity.ts    From typeorm-query-builder-wrapper with MIT License 5 votes vote down vote up
@Entity('ptc_users')
export class User extends BaseEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'boolean', name: 'is_deleted', default: false })
  isDeleted: boolean;

  @CreateDateColumn({
    type: 'timestamp',
    name: 'create_date_time',
  })
  createDateTime: Date;

  @UpdateDateColumn({
    type: 'timestamp',
    name: 'update_date_time',
  })
  updateDateTime: Date;

  @Column('character varying', {
    nullable: false,
    length: 255,
    name: 'name',
  })
  name: string;

  @Column('character varying', {
    nullable: false,
    length: 255,
    name: 'username',
  })
  username: string;

  @Column('character varying', {
    nullable: false,
    length: 500,
    name: 'password',
    select: false,
  })
  password: string;

  @Column('character varying', {
    nullable: true,
    length: 255,
    name: 'email',
  })
  email: string | null;

  @Column('numeric', {
    nullable: false,
    name: 'point',
  })
  point: number;

  @Column('numeric', {
    nullable: false,
    name: 'follower',
  })
  follower: number;

  @Column('numeric', {
    nullable: false,
    name: 'following',
  })
  following: number;

  @ManyToMany(() => Photos, { cascade: true })
  @JoinTable()
  photos?: Photos[];
}
Example #29
Source File: Post.ts    From lireddit with MIT License 5 votes vote down vote up
@ObjectType()
@Entity()
export class Post extends BaseEntity {
  @Field()
  @PrimaryGeneratedColumn()
  id!: number;

  @Field()
  @Column()
  title!: string;

  @Field()
  @Column()
  text!: string;

  @Field()
  @Column({ type: "int", default: 0 })
  points!: number;

  @Field(() => Int, { nullable: true })
  voteStatus: number | null; // 1 or -1 or null

  @Field()
  @Column()
  creatorId: number;

  @Field()
  @ManyToOne(() => User, (user) => user.posts)
  creator: User;

  @OneToMany(() => Updoot, (updoot) => updoot.post)
  updoots: Updoot[];

  @Field(() => String)
  @CreateDateColumn()
  createdAt: Date;

  @Field(() => String)
  @UpdateDateColumn()
  updatedAt: Date;
}