# Schema Decorator

Module
import { Schema } from "@tsed/mongoose"
Source/packages/mongoose/src/decorators/schema.ts

# Overview

function Schema(options?: MongooseSchemaOptions): (target: any) => void;
function Schema(definition: SchemaTypeOpts<any>): Function;

# Description

Define a class as a Mongoose Schema ready to be used to compose other schemes and models.

# Example

@Schema()
export class EventSchema {
  @Property()
  field: string;
}
1
2
3
4
5

# Options

  • schemaOptions (mongoose.SchemaOptions): Option to configure the schema behavior.