# Decorator Immutable

Decorator mongoose property
Module
import { Immutable } from "@tsed/mongoose"
Source/packages/mongoose/src/decorators/immutable.ts

# Overview

function Immutable(immutable?: boolean | ((this: any, doc: any) => boolean)): PropertyDecorator;

# Description

If truthy (opens new window), Mongoose will disallow changes to this path once the document is saved to the database for the first time. Read more about immutability in Mongoose here (opens new window).

# Example

@Model()
export class EventModel {
  @Immutable()
  field: string;
}
1
2
3
4
5

Other topics