How to use the @typegoose/typegoose.modelOptions function in @typegoose/typegoose

To help you get started, we’ve selected a few @typegoose/typegoose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github topfullstack / topfullstack / server / libs / db / src / models / user.model.ts View on Github external
import { prop, modelOptions } from '@typegoose/typegoose'
import { ApiProperty } from '@nestjs/swagger'

@modelOptions({
  schemaOptions: {
    timestamps: true
  }
})
export class User {
  @ApiProperty({ description: '用户名', example: 'user1' })
  @prop()
  username: string

  @ApiProperty({ description: '密码', example: 'pass1' })
  @prop()
  password: string
}
github topfullstack / topfullstack / server / libs / db / src / models / course.model.ts View on Github external
import { prop, modelOptions, arrayProp, Ref } from '@typegoose/typegoose';
import { ApiProperty } from '@nestjs/swagger';
import { Episode } from './episode.model';

@modelOptions({
  schemaOptions: {
    timestamps: true,
    toJSON: { virtuals: true },
  },
})
export class Course {
  @ApiProperty({ description: '课程名称' })
  @prop()
  name: string;

  @ApiProperty({ description: '封面图' })
  @prop()
  cover: string;

  @arrayProp({
    ref: 'Episode',
github topfullstack / topfullstack / server / libs / db / src / models / episode.model.ts View on Github external
import { prop, modelOptions, Ref } from "@typegoose/typegoose";
import { Course } from "./course.model";

@modelOptions({
  schemaOptions: {
    timestamps: true
  }
})
export class Episode {
  @prop()
  name: string

  @prop()
  file: string

  @prop({ ref: 'Course' })
  course: Ref

}

@typegoose/typegoose

Define Mongoose models using TypeScript classes

MIT
Latest version published 10 days ago

Package Health Score

89 / 100
Full package analysis