Created
April 19, 2022 01:46
-
-
Save thedewpoint/be1ed8e608ba52fb02293ffb30d42645 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity, Column, ObjectIdColumn, ObjectID } from 'typeorm'; | |
import { DateTime } from 'luxon'; | |
import { UpdateSubscriptionDto } from '../dto/update-subscription.dto'; | |
import { CreateSubscriptionDto } from '../dto/create-subscription.dto'; | |
@Entity('subscriptions') | |
export class Subscription { | |
constructor(subscriptionDTO?: UpdateSubscriptionDto | CreateSubscriptionDto) { | |
this.userId = subscriptionDTO?.userId; | |
this.active = subscriptionDTO?.active ?? true; | |
this.createDate = | |
subscriptionDTO?.createDate ?? DateTime.now().toUTC().toUnixInteger(); | |
if (subscriptionDTO && subscriptionDTO instanceof UpdateSubscriptionDto) { | |
this.lastBilledAt = subscriptionDTO?.lastBilledAt; | |
this.id = subscriptionDTO?.id; | |
} | |
} | |
@ObjectIdColumn() | |
id: ObjectID; | |
@ObjectIdColumn() | |
userId: ObjectID; | |
@ObjectIdColumn() | |
price: number; | |
@Column() | |
createDate: number; | |
@Column() | |
lastBilledAt: number; | |
@Column() | |
active: boolean; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment