How to use the sequelize-typescript.Table 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 midwayjs / midway-examples / demo-sequelize-typescript / src / lib / model / post.ts View on Github external
{
    id: 'PostModel',
    provider: factory,
  },
]);
// you need to export the type of Model class to ensure
// type-safety outside
export type IPostModel = typeof PostModel;

@Scopes({
  // a self-defined scope means "non-soft-deleted rows"
  avaliable: {
    where: {status: 1},
  },
})
@Table({
  // you can claim your tableName explicitly
  freezeTableName: true,
  tableName: 'my_posts_table',
})
export class PostModel extends Model {

  @Column({
    type: BIGINT(20),
    primaryKey: true,
    autoIncrement: true,
    comment: 'post id',
  })
  id: number;

  @Column({
    type: STRING(1024),
github RiseVision / rise-node / src / models / MemRoundsModel.ts View on Github external
// tslint:disable
import { Column, DataType, ForeignKey, Model, PrimaryKey, Table } from 'sequelize-typescript';
import 'reflect-metadata';
import { publicKey } from '../types/sanityTypes';
import { BlocksModel } from './BlocksModel';
import { AccountsModel } from './AccountsModel';


@Table({ tableName: 'mem_rounds' })
export class MemRoundsModel extends Model {
  @PrimaryKey
  @ForeignKey(() => AccountsModel)
  @Column
  public address: string;

  @PrimaryKey
  @Column
  public amount: number;

  @PrimaryKey
  @Column(DataType.TEXT)
  public delegate: publicKey;

  @PrimaryKey
  @ForeignKey(() => BlocksModel)
github turt2live / matrix-dimension / src / db / models / NebIntegration.ts View on Github external
import { AutoIncrement, Column, ForeignKey, Model, PrimaryKey, Table } from "sequelize-typescript";
import { IntegrationRecord } from "./IntegrationRecord";
import NebConfiguration from "./NebConfiguration";

@Table({
    tableName: "dimension_neb_integrations",
    underscored: false,
    timestamps: false,
})
export default class NebIntegration extends Model implements IntegrationRecord {
    @PrimaryKey
    @AutoIncrement
    @Column
    id: number;

    @Column
    type: string;

    @Column
    name: string;
github T-Systems-RUS / Portfolio / server / models / Role.ts View on Github external
import {Model, AllowNull, DataType, Column, Table, Scopes, CreatedAt, UpdatedAt, HasMany} from 'sequelize-typescript';
import {Schedule} from './Schedule';
import {Tables} from '../sequelize/Tables';

@Scopes({
    withSchedules: {
        include: [() => Schedule ]
    }
})
@Table({
    timestamps: true,
    tableName: Tables.ROLES
})
export class Role extends Model {

    @AllowNull(false)
    @Column
    name: string;

    @AllowNull(false)
    @Column
    domain: string;

    @Column
    leadrole: boolean;
github turt2live / matrix-voyager-bot / src / models / room.ts View on Github external
import { Column, Model, PrimaryKey, Table } from "sequelize-typescript";

@Table({
    tableName: "voyager_rooms",
    underscoredAll: false,
    timestamps: false,
})
export default class Room extends Model {
    @PrimaryKey
    @Column
    roomId: string;

    @Column
    userCount: number;

    @Column
    serverCount: number;

    @Column
github turt2live / matrix-dimension / src / db / models / UserScalarToken.ts View on Github external
import {
    AllowNull,
    AutoIncrement,
    BelongsTo,
    Column,
    ForeignKey,
    Model,
    PrimaryKey,
    Table
} from "sequelize-typescript";
import User from "./User";
import Upstream from "./Upstream";

@Table({
    tableName: "dimension_scalar_tokens",
    underscored: false,
    timestamps: false,
})
export default class UserScalarToken extends Model {
    @PrimaryKey
    @AutoIncrement
    @Column
    id: number;

    @Column
    @ForeignKey(() => User)
    userId: string;

    @BelongsTo(() => User)
    user: User;
github RiseVision / rise-node / packages / core-p2p / src / PeersModel.ts View on Github external
import { IPeersModel, PeerState } from '@risevision/core-types';
import { Column, DataType, Model, Table } from 'sequelize-typescript';

@Table({ tableName: 'peers', timestamps: false })
export class PeersModel extends Model implements IPeersModel {
  @Column
  public ip: string;

  @Column
  public port: number;

  @Column(DataType.SMALLINT)
  public state: PeerState;

  @Column
  public os: string;

  @Column
  public version: string;
github turt2live / matrix-dimension / src / db / models / TelegramBridgeRecord.ts View on Github external
import { AllowNull, AutoIncrement, Column, ForeignKey, Model, PrimaryKey, Table } from "sequelize-typescript";
import Upstream from "./Upstream";

@Table({
    tableName: "dimension_telegram_bridges",
    underscored: false,
    timestamps: false,
})
export default class TelegramBridgeRecord extends Model {
    @PrimaryKey
    @AutoIncrement
    @Column
    id: number;

    @AllowNull
    @Column
    @ForeignKey(() => Upstream)
    upstreamId?: number;

    @AllowNull
github WeebSearch / worker / src / database / entities / character.ts View on Github external
import {
  AutoIncrement, BelongsTo,
  BelongsToMany,
  Column,
  CreatedAt, ForeignKey, HasMany,
  Model,
  PrimaryKey,
  Table,
  UpdatedAt
} from "sequelize-typescript";
import CharacterDiscovery from "./character_discovery";

@Table({
  tableName: "characters",
  underscored: true
})
export default class Character extends Model {
  @AutoIncrement @PrimaryKey @Column
  public readonly id: number;

  @Column({ allowNull: false, unique: true })
  public readonly anilistId: number;

  @Column
  public readonly name: string;

  @Column
  public readonly thumbnailUrl: string;