@iamcalegari/mongoat / Prop
Function: Prop()
Prop(
fragment): (_value,context) =>void
Defined in: src/schema/decorators.ts:64
Canonical field decorator: declares the JSON Schema fragment for the decorated field. The fragment is written verbatim into the compiled schema — an omitted bsonType simply means "no type restriction" (pure JSON Schema semantics, no magic default).
Fields decorated with Prop are required by default. Fields without any decorator are invisible to decorators (a TC39 limitation) and stay OUT of the compiled schema entirely.
Prop only records metadata — it never changes the runtime value or the initializer of the field.
Parameters
fragment
PropFragment
Returns
(_value, context) => void
Example
typescript
class UserSchema {
@Prop({ bsonType: 'string' })
username!: string;
}