Skip to content

UnixTimestampType

Defined in: packages/ddd-mikro-orm/src/mapping/unix-timestamp.type.ts:47

MikroORM type that stores a Date as epoch milliseconds in a 64-bit bigint column.

null and undefined pass through in both directions. A value that has no valid time throws a TypeError rather than being stored or returned as NaN.

  • Type<Date | null | undefined, number | null | undefined>

new UnixTimestampType(): UnixTimestampType

UnixTimestampType

Type< Date | null | undefined, number | null | undefined >.constructor

optional meta?: EntityMetadata<any, EntityCtor<any>>

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:22

Type.meta


optional platform?: Platform

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:21

Type.platform


optional prop?: EntityProperty<any, any>

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:23

Type.prop

get name(): string

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:50

string

Type.name


get runtimeType(): string

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:49

string

Type.runtimeType

compareAsType(): string

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:44

How should the raw database values be compared? Used in EntityComparator. Possible values: string | number | bigint | boolean | date | any | buffer | array

string

Type.compareAsType


optional compareValues(a, b): boolean

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:48

Allows to override the internal comparison logic.

number | null | undefined

number | null | undefined

boolean

Type.compareValues


convertToDatabaseValue(value, _platform?, _context?): number | null | undefined

Defined in: packages/ddd-mikro-orm/src/mapping/unix-timestamp.type.ts:51

Converts a value from its JS representation to its database representation of this type.

Timestamp | null | undefined

Platform

TransformContext

number | null | undefined

Type.convertToDatabaseValue


optional convertToDatabaseValueSQL(key, platform): string

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:35

Converts a value from its JS representation to its database representation of this type.

string

Platform

string

Type.convertToDatabaseValueSQL


convertToJSValue(value, _platform?, _context?): Date | null | undefined

Defined in: packages/ddd-mikro-orm/src/mapping/unix-timestamp.type.ts:60

Converts a value from its database representation to its JS representation of this type.

Timestamp | null | undefined

Platform

TransformContext

Date | null | undefined

Type.convertToJSValue


optional convertToJSValueSQL(key, platform): string

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:39

Modifies the SQL expression (identifier, parameter) to convert to a JS value.

string

Platform

string

Type.convertToJSValueSQL


ensureComparable<T>(meta, prop): boolean

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:56

When a value is hydrated, we convert it back to the database value to ensure comparability, as often the raw database response is not the same as the convertToDatabaseValue result. This allows to disable the additional conversion in case you know it is not needed.

T extends object

EntityMetadata<T>

EntityProperty<T>

boolean

Type.ensureComparable


optional fromJSON(value, platform): Date | null | undefined

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:72

Converts a value from its serialized JSON form back to its JS representation. Used when decoding cursor values. The input is what toJSON produced, after a JSON.parse round trip, and never an already restored JS value. Cursors are client supplied, so the value can be any JSON shape: validate it and throw for values the type cannot restore, and findByCursor surfaces the failure as a CursorError. Implementing this method also makes cursor encoding use toJSON. Without it, cursors carry the raw JS value, and decoding falls back to convertToJSValue, with type-based Date restoration for date-like columns.

unknown

Platform

Date | null | undefined

Type.fromJSON


getColumnType(prop?, platform?): string

Defined in: packages/ddd-mikro-orm/src/mapping/unix-timestamp.type.ts:70

Gets the SQL declaration snippet for a field of this type.

EntityProperty = ...

Platform

string

Type.getColumnType


optional getDefaultLength(platform): number

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:91

Get the default length for values of this type

When doing schema generation, if neither “length” nor “columnType” option is provided, the length will be defaulted to this value.

When doing entity generation, if the type is recognized to this type, and the inferred length is this value, the length option will be omitted in the output. If this method is not defined, length is always outputted based on what is in the database metadata.

Platform

The platform the default will be used for.

number

The default value for the given platform.

Type.getDefaultLength


toJSON(value, platform): number | Date | null | undefined

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:61

Converts a value from its JS representation to its serialized JSON form of this type. By default uses the runtime value.

Date | null | undefined

Platform

number | Date | null | undefined

Type.toJSON


static getOrmType(cls): string | undefined

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:102

Internal

Returns the built-in type registry key if the given constructor is a branded ORM type (not a user subclass). Uses Symbol.for() so it works across CJS/ESM module graphs.

object

string | undefined

Type.getOrmType


static getType<JSType, DBType, TypeClass>(cls): InstanceType<TypeClass>

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:92

JSType

DBType = JSType

TypeClass extends Constructor<Type<JSType, DBType>> = Constructor<Type<JSType, DBType>>

TypeClass

InstanceType<TypeClass>

Type.getType


static isMappedType(data): data is Type<any, any>

Defined in: node_modules/.pnpm/@mikro-orm+core@7.2.1/node_modules/@mikro-orm/core/types/Type.d.ts:96

Checks whether the argument is instance of Type.

any

data is Type<any, any>

Type.isMappedType