Created
October 8, 2020 10:52
-
-
Save velotiotech/42323ae89141a0c0c9bbe96c8e7e0738 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 { DocumentType, getModelForClass, prop as Property } from '@typegoose/typegoose'; | |
import { getSchemaOptions } from 'src/util/typegoose'; | |
import { Field as GqlField, ObjectType as GqlType } from 'type-graphql'; | |
@GqlType() | |
export class User { | |
@GqlField(_type => String) | |
readonly _id: string; | |
@GqlField(_type => String) | |
@Property({ required: true }) | |
firstName: string; | |
@GqlField(_type => String, { nullable: true }) | |
@Property({ required: false }) | |
lastName: string; | |
@GqlField(_type => String) | |
@Property({ required: true }) | |
password: string; | |
@GqlField(_type => String) | |
@Property({ required: true, unique: true }) | |
email: string; | |
hashPassword(this: DocumentType<User>, _password: string) { | |
// logic to hash passwords | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment