My entities:

@Entity()
export class AccessUser extends BaseEntity  {
    
     @ManyToOne(() => UserName, { onUpdateIntegrity: "no action"})
     userName: UserName;

    @ManyToMany(() => Right, a => a.accessUsers, {}/*"accessUsers")
    rights = new Collection<Right>(this);

  .....
}
@Entity()
export class Right extends BaseEntity {

    @Property()
    right: string;

    @ManyToMany(() => AccessUser)
    accessUsers = new Collection<AccessUser>(this);
}

export abstract class BaseEntity {

  @PrimaryKey()
  _id!: ObjectId;

  @SerializedPrimaryKey()
  id!: string;

  @Property()
  createdAt = new Date();

  @Property({ onUpdate: () => new Date() })
  updatedAt = new Date();

}
0

There are 0 best solutions below