2019-11-24 18:27:01 +01:00
|
|
|
import { Check, Column } from 'typeorm';
|
2019-11-22 21:22:13 +01:00
|
|
|
|
2019-11-24 16:35:01 +01:00
|
|
|
export const minValue = 0;
|
|
|
|
export const maxValue = Number.MAX_SAFE_INTEGER;
|
|
|
|
|
|
|
|
export interface IRateable {
|
|
|
|
rating: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function Rateable<T extends Constructor>(BaseClass: T = null): T {
|
|
|
|
@Check(`rating >= ${minValue} AND rating <= ${maxValue}`)
|
|
|
|
class MixinClass extends BaseClass implements IRateable {
|
2019-11-22 21:22:13 +01:00
|
|
|
@Column({ nullable: true })
|
|
|
|
public rating: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MixinClass;
|
|
|
|
}
|