Registry / database / mikro-orm-temporal

mikro-orm-temporal

JSON →
library2.0.2jsnpmunverified

Provides Mikro ORM property types for the TC39 Temporal API objects including Duration, PlainDate, PlainDateTime, PlainTime, ZonedDateTime, Instant, PlainMonthDay, and PlainYearMonth. Current version 2.0.2 requires @mikro-orm/core >= 7.0.1. Supports Postgres, MySQL, MariaDB. This library integrates Temporal types into Mikro ORM's schema and query system, mapping them to appropriate database column types (e.g., INTERVAL for durations in Postgres, VARCHAR for others). It is the only known Mikro ORM extension for Temporal objects, filling a gap for modern date/time handling without legacy Date issues.

npm install mikro-orm-temporal
INSTALL
IMPORT
SIG · MIKRO-ORM-TEMPORAL
M
mikro-orm-temporal
databasejavascriptv2.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DurationType
import { DurationType } from 'mikro-orm-temporal'
const DurationType = require('mikro-orm-temporal').DurationType
ESM-only; CommonJS require requires .default or destructuring
PlainDateType
import { PlainDateType } from 'mikro-orm-temporal'
Named export, no default export.
OffsetDateTimeType
import { OffsetDateTimeType } from 'mikro-orm-temporal'
For ZonedDateTime Temporal objects.
InstantType
import { InstantType } from 'mikro-orm-temporal'
For Temporal.Instant.

Defines a Mikro ORM entity with temporal fields using OffsetDateTimeType, PlainDateType, and DurationType.

import { defineEntity, p } from '@mikro-orm/core'; import { DurationType, PlainDateType, OffsetDateTimeType } from 'mikro-orm-temporal'; const EventSchema = defineEntity({ name: 'Event', properties: { id: p.integer().primary(), startsAt: p.type(OffsetDateTimeType), endsAt: () => p.type(OffsetDateTimeType).nullable(), date: p.type(PlainDateType), duration: p.type(DurationType), }, }); export class Event extends EventSchema.class {} EventSchema.setClass(Event);
Debug
Known issues
breakingVersion 2.x requires @mikro-orm/core >= 7.0.1. Older versions are incompatible.
fix
Upgrade @mikro-orm/core to version 7.0.1 or higher.
affects: >=2.0 <3.0
gotchaDuration is stored as INTERVAL in Postgres but as VARCHAR (ISO 8601 string) in other databases like MySQL/MariaDB.
fix
Ensure your queries and migrations handle the difference; for MySQL, parsed ISO strings on read.
affects: *
deprecatedThe Temporal API is still experimental in Node.js (behind --harmony-temporal flag) and may have spec changes until Stage 4.
fix
Use polyfill like @js-temporal/polyfill if needed; monitor ECMAScript Temporal proposal status.
affects: *
gotchaThe package does not provide a type-level default export; only named imports work.
fix
Use import { TypeName } from 'mikro-orm-temporal' instead of default import.
affects: *
Errors
Common errors & fixes
Cannot find module 'mikro-orm-temporal' or its corresponding type declarations.
Package is not installed or TypeScript cannot resolve the module.
fix
Install the package: npm install mikro-orm-temporal. Ensure tsconfig.json includes node_modules in typeRoots or have 'skipLibCheck': false.
Property 'type' does not exist on type 'p'.
Using an outdated version of @mikro-orm/core (< 7.0) or incorrect import.
fix
Upgrade @mikro-orm/core to >= 7.0.1 and use import { p } from '@mikro-orm/core'.
Argument of type 'typeof OffsetDateTimeType' is not assignable to parameter of type 'Type<any, any>'.
Type mismatch due to Mikro ORM Type generic constraints.
fix
Ensure you are using the correct import and that the Type class matches the expected signature. If still failing, check Mikro ORM version compatibility.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
@mikro-orm/corerequiredPeer dependency: required to use Mikro ORM's type system
Agent activity
3 hits · last 30 days
node
2
Resources
mikro-orm-temporal — npm install mikro-orm-temporal · libregistry