Skip to content

NumberDecimal

@tsed/mongoose

Usage

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

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

Overview

ts
function NumberDecimal(type?: any): any;
  • type (any): Optional. decimal type constructor

Description

Tell Mongoose whether to define an Decimal128 property. Will be serialized as number with format as decimal.

Example

typescript
@Model()
export class PriceModel {
  @NumberDecimal()
  price: Decimal128;
}

Optionally using custom decimal type, such as Big from big.js

typescript
@Model()
export class PriceModel {
  @NumberDecimal(Big)
  price: Big;
}

Released under the MIT License.