Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created October 8, 2020 10:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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