Skip to content

monolayer-pg / schema / numeric

Function: numeric()

numeric(precision?, scale?): PgNumeric

Column that can store numbers with a very large number of digits.

Parameters

ParameterTypeDescription
precision?numberTotal count of significant digits in the whole number (number of digits to both sides of the decimal point). Must be positive.
scale?numberCount of decimal digits in the fractional part, to the right of the decimal point. Can be positive or negative.

Returns

PgNumeric

Remarks

Without any precision or scale numeric values of any length can be stored, up to the implementation limits.

In addition to ordinary numeric values, it can store several special values:

  • Infinity
  • -Infinity
  • NaN

Kysely database schema type definition

ts
{
  readonly __select__: string | null;
  readonly __insert__: bigint | number | string | null | undefined;
  readonly __update__: bigint | number | string | string | null;
};

Nullability and optionality will change according to the column's constraints, generated values, and default data values.

Example

ts
import { schema, numeric, table } from "@monolayer/pg/schema";

const dbSchema = schema({
  tables: {
    example: table({
      columns: {
        amount: numeric(),
      },
    }),
  },
});

// Kysely database schema type
type DB = typeof dbSchema.infer;

See

numeric (PostgreSQL Docs)