Skip to content

Instantly share code, notes, and snippets.

@elie222
Created April 10, 2019 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elie222/2ca47760af466d23b18eddca7a63e9f1 to your computer and use it in GitHub Desktop.
Save elie222/2ca47760af466d23b18eddca7a63e9f1 to your computer and use it in GitHub Desktop.
Using TypeORM (MongoDB) and TypeGraphQL together
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