Created
April 10, 2019 22:05
-
-
Save elie222/2ca47760af466d23b18eddca7a63e9f1 to your computer and use it in GitHub Desktop.
Using TypeORM (MongoDB) and TypeGraphQL together
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 { Field, ObjectType, ID } from 'type-graphql' | |
import { | |
Entity, | |
ObjectIdColumn, | |
ObjectID, | |
Column, | |
CreateDateColumn, | |
UpdateDateColumn, | |
} from 'typeorm' | |
@ObjectType() | |
@Entity() | |
export default class Policy { | |
@Field(type => ID) | |
@ObjectIdColumn() | |
_id: ObjectID | |
@Field() | |
@CreateDateColumn({ type: 'timestamp' }) | |
createdAt: Date | |
@Field({ nullable: true }) | |
@UpdateDateColumn({ type: 'timestamp', nullable: true }) | |
updatedAt?: Date | |
@Field() | |
@Column() | |
name: string | |
@Field() | |
@Column() | |
version: number | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment