Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created October 8, 2020 10:52
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 velotiotech/42323ae89141a0c0c9bbe96c8e7e0738 to your computer and use it in GitHub Desktop.
Save velotiotech/42323ae89141a0c0c9bbe96c8e7e0738 to your computer and use it in GitHub Desktop.
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