How to use the sequelize-typescript.DataType.UUIDV4 function in sequelize-typescript

To help you get started, we’ve selected a few sequelize-typescript 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 birkir / prime / packages / prime-core / src / models / ContentRelease.ts View on Github external
import { Column, DataType, Default, Model, PrimaryKey, Table } from 'sequelize-typescript';

@Table({ timestamps: true })
export class ContentRelease extends Model {
  @PrimaryKey
  @Default(DataType.UUIDV4)
  @Column(DataType.UUID)
  public id: any;

  @Column
  public name: string;

  @Column
  public description: string;

  @Column
  public scheduledAt: Date;

  @Column
  public publishedAt: Date;

  @Column(DataType.UUID)
github birkir / prime / packages / prime-core / src / models / Settings.ts View on Github external
flag: 'us',
      master: true,
    };

    const masterLocale = [].concat(settings.locales).find((locale: any) => locale && locale.master);

    if (!masterLocale) {
      settings.locales.push(defaultLocale);
    }

    settings.masterLocale = [].concat(settings.locales).find((locale: any) => locale && locale.master);

    return settings;
  }
  @PrimaryKey
  @Default(DataType.UUIDV4)
  @Column(DataType.UUID)
  public id: any;

  @Column(DataType.JSONB)
  public data: any;

  @Column(DataType.UUID)
  public userId;

  @CreatedAt
  @Column
  public createdAt: Date;

  @UpdatedAt
  @Column
  public updatedAt: Date;
github primecms / heroku / src / models / ContentType.ts View on Github external
import { Model, Column, Table, HasMany, PrimaryKey, DataType } from 'sequelize-typescript';
import { ContentEntry } from './ContentEntry';
import { ContentTypeField } from './ContentTypeField';

@Table
export class ContentType extends Model {

  @PrimaryKey
  @Column({
    type: DataType.UUID,
    defaultValue: DataType.UUIDV4
  })
  id;

  @Column
  name: string;

  @HasMany(() => ContentEntry)
  contentEntry: ContentEntry;

  @HasMany(() => ContentTypeField)
  fields: ContentTypeField[];
}
github birkir / prime / packages / prime-core / src / models / WebhookCall.ts View on Github external
import { BelongsTo, Column, DataType, Default, Model, PrimaryKey, Table } from 'sequelize-typescript';
import { Webhook } from './Webhook';

@Table
export class WebhookCall extends Model {
  @PrimaryKey
  @Default(DataType.UUIDV4)
  @Column(DataType.UUID)
  public id;

  @Column(DataType.UUID)
  public webhookId: any;

  @Column(DataType.BOOLEAN)
  public success: any;

  @Column(DataType.INTEGER)
  public status: number;

  @Column(DataType.JSONB)
  public request: any;

  @Column(DataType.JSONB)
github primecms / heroku / src / models / ContentEntry.ts View on Github external
@Scopes({
  contentType: {
    include: [{
      model: () => ContentType,
      through: { attributes: [] },
    }],
  },
})
@Table
export class ContentEntry extends Model {

  @PrimaryKey
  @Column({
    type: DataType.UUID,
    defaultValue: DataType.UUIDV4
  })
  id;

  @Column(DataType.UUID)
  @ForeignKey(() => ContentType)
  contentTypeId;

  @Column
  language: string;

  @Column(DataType.JSON)
  data;

  @BelongsTo(() => ContentType)
  contentType: ContentType;
}
github birkir / prime / packages / prime-core / src / models / Navigation.ts View on Github external
import { Column, DataType, Model, PrimaryKey, Table } from 'sequelize-typescript';

@Table
export class Navigation extends Model {
  @PrimaryKey
  @Column({
    type: DataType.UUID,
    defaultValue: DataType.UUIDV4,
  })
  public id;

  @Column(DataType.UUID)
  public parentNavigationId;

  @Column(DataType.STRING)
  public name: string;

  @Column(DataType.UUID)
  public contentTypeId: string;

  @Column(DataType.UUID)
  public contentEntryId: string;

  @Column(DataType.BOOLEAN)
github birkir / prime / packages / prime-core / src / models / User.ts View on Github external
Model,
  PrimaryKey,
  Table,
  Unique,
} from 'sequelize-typescript';

@Table({ timestamps: true })
export class User extends Model {
  @BeforeCreate
  public static HASH_PASSWORD(instance: User) {
    instance.password = bcrypt.hashSync(instance.password, 10);
  }
  @PrimaryKey
  @Column({
    type: DataType.UUID,
    defaultValue: DataType.UUIDV4,
  })
  public id;

  @Column
  public firstname: string;

  @Column
  public lastname: string;

  @Column
  public displayName: string;

  @Column
  public avatarUrl: string;

  @IsEmail
github birkir / prime / packages / prime-core / src / models / ContentTypeField.ts View on Github external
import { JSON } from 'sequelize';
import { BelongsTo, Column, DataType, Default, ForeignKey, Model, PrimaryKey, Table } from 'sequelize-typescript';
import { fields } from '../fields';
import { ContentType } from './ContentType';

@Table
export class ContentTypeField extends Model {
  @PrimaryKey
  @Column({
    type: DataType.UUID,
    defaultValue: DataType.UUIDV4,
  })
  public id: string;

  @Column
  public name: string;

  @Column
  public title: string;

  @Column
  public description: string;

  @Column
  public type: string;

  @Default('Main')
github birkir / prime / packages / prime-core / src / models / ContentEntry.ts View on Github external
public static async GET_RANDOM_ID() {
    const entryId = hashid.encode(+new Date());
    const count = await ContentEntry.count({
      where: {
        entryId,
      },
    });

    return count === 0 ? entryId : ContentEntry.GET_RANDOM_ID();
  }
  @Column(DataType.STRING)
  public entryId: string;

  @PrimaryKey
  @Default(DataType.UUIDV4)
  @Column(DataType.UUID)
  public versionId: any;

  @ForeignKey(() => ContentType)
  @Column(DataType.UUID)
  public contentTypeId: any;

  @ForeignKey(() => ContentRelease)
  @Column(DataType.UUID)
  public contentReleaseId: any;

  @Default('en')
  @Column
  public language: string;

  @Column