Skip to content

Sparse

@tsed/mongoose

Usage

typescript
import { Sparse } from "@tsed/mongoose";

See /packages/orm/mongoose/src/types/decorators/sparse.ts.

Overview

ts
function Sparse(sparse?: boolean | number): PropertyDecorator;

Description

If truthy, 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.

Example

typescript
@Model()
export class EventModel {
  @Sparse()
  field: string;
}

Released under the MIT License.