How to use the sequelize-typescript.HasMany 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 BigsonLvrocha / relay-modern-typescript-server / src / models / User.model.ts View on Github external
@BeforeCreate({ name: "giveId" }) static async giveId(instance: User) {
    instance._id = uuid();
    instance.password = await bcrypt.hash(instance.password, 10);
  }

  @Column name: string;
  @Column({
    primaryKey: true
  })
  // tslint:disable-next-line: variable-name
  _id: string;
  @Column email: string;
  @Column password: string;
  @Column active: boolean;

  @HasMany(() => Post, "authorId")
  posts: Post[];
}
github thx / rap2-delos / src / models / bo / repository.ts View on Github external
@BelongsTo(() => User, 'ownerId')
  owner: User

  @BelongsTo(() => Organization, 'organizationId')
  organization: Organization

  @BelongsTo(() => User, 'lockerId')
  locker: User

  @BelongsToMany(() => User, 'repositories_members', 'repositoryId', 'userId')
  members: User[]

  @HasMany(() => Module, 'repositoryId')
  modules: Module[]

  @HasMany(() => Module, 'repositoryId')
  interfaces: Interface[]

  @BelongsToMany(() => Repository, () => RepositoriesCollaborators, 'repositoryId', 'collaboratorId')
  collaborators: Repository[]

  @BelongsToMany(() => Repository, () => RepositoriesCollaborators, 'collaboratorId')
  repositories: Repository[]

}
github thx / rap2-delos / src / models / bo / module.ts View on Github external
@ForeignKey(() => User)
  @Column
  creatorId: number

  @ForeignKey(() => Repository)
  @Column
  repositoryId: number

  @BelongsTo(() => User, 'creatorId')
  creator: User

  @BelongsTo(() => Repository, 'repositoryId')
  repository: Repository

  @HasMany(() => Interface, 'moduleId')
  interfaces: Interface[]
}
github thx / rap2-delos / src / models / bo / interface.ts View on Github external
@Column
  repositoryId: number

  @BelongsTo(() => User, 'creatorId')
  creator: User

  @BelongsTo(() => User, 'lockerId')
  locker: User

  @BelongsTo(() => Module, 'moduleId')
  module: Module

  @BelongsTo(() => Repository, 'repositoryId')
  repository: Repository

  @HasMany(() => Property, 'interfaceId')
  properties: Property[]

}
github thx / rap2-delos / src / models / bo / organization.ts View on Github external
@Column
  ownerId: number

  @BelongsTo(() => User, 'creatorId')
  creator: User

  @BelongsTo(() => User, 'ownerId')
  owner: User

  @BelongsToMany(() => User, () => OrganizationsMembers)
  members: User[]

  @HasMany(() => OrganizationsMembers)
  organizationMembersList: OrganizationsMembers[]

  @HasMany(() => Repository, 'organizationId')
  repositories: Repository[]
}
github thx / rap2-delos / src / models / bo / user.ts View on Github external
@Column(DataType.STRING(32))
  password: string

  @AllowNull(false)
  @Unique
  @Column(DataType.STRING(128))
  email: string

  @HasMany(() => Organization, 'ownerId')
  ownedOrganizations: Organization[]

  @BelongsToMany(() => Organization, () => OrganizationsMembers)
  joinedOrganizations: Organization[]

  @HasMany(() => Repository, 'ownerId')
  ownedRepositories: Repository[]

  @BelongsToMany(() => Repository, () => RepositoriesMembers)
  joinedRepositories: Repository[]

}
github oughtinc / mosaic / server / lib / models / experiment.ts View on Github external
@Default(true)
  @Column(DataType.BOOLEAN)
  public areNewWorkspacesOracleOnlyByDefault: boolean;

  @BelongsToMany(() => Tree, "ExperimentTreeRelation", "ExperimentId", "TreeId")
  public trees: Tree[];

  @BelongsToMany(
    () => Experiment,
    "FallbackRelation",
    "primaryExperimentId",
    "fallbackExperimentId",
  )
  public fallbacks: Experiment[];

  @HasMany(() => Instructions, "experimentId")
  public instructions: Instructions[];

  @HasMany(() => NotificationRequest, "experimentId")
  public notificationRequests: NotificationRequest[];

  @AfterCreate
  public static async createDefaultInstructions(experiment: Experiment) {
    await Instructions.bulkCreate([
      {
        experimentId: experiment.id,
        type: "root",
        value: defaultRootInstructions,
      },
      {
        experimentId: experiment.id,
        type: "honestOracle",
github oughtinc / mosaic / server / lib / models / user.ts View on Github external
@Column(DataType.STRING)
  public email: string;

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

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

  @Column(DataType.BOOLEAN)
  public isAdmin: boolean;

  @BelongsToMany(() => Tree, () => UserTreeOracleRelation)
  public OracleTrees: Tree[];

  @HasMany(() => NotificationRequest, "userId")
  public notificationRequests: NotificationRequest[];
}