Registry / database / mikro-orm-js-joda

mikro-orm-js-joda

JSON →
library1.1.5jsnpmunverified

Provides Mikro ORM custom type classes for JS Joda objects, including LocalDateType, LocalTimeType, and ZonedDateTimeType for mapping between JS Joda and database columns. Current stable version is 1.1.5, released as needed alongside peer upgrades. Requires @js-joda/core ^5.6.1 and @mikro-orm/core ^6.0.5. Differentiators: first-class MikroORM v6 integration with TypeScript; only package offering these specific custom types for MikroORM; supports mapping of LocalDate, LocalTime, and ZonedDateTime to database types while handling timezone and precision differences.

npm install mikro-orm-js-joda
INSTALL
IMPORT
SIG · MIKRO-ORM-JS-JODA
M
mikro-orm-js-joda
databasejavascriptv1.1.5
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.

ZonedDateTimeType
import { ZonedDateTimeType } from 'mikro-orm-js-joda'
const { ZonedDateTimeType } = require('mikro-orm-js-joda')
ESM-only package; do not use CommonJS require().
LocalDateType
import { LocalDateType } from 'mikro-orm-js-joda'
import { LocalDate } from 'mikro-orm-js-joda'
The library exports type classes, not the JS Joda core classes. Import LocalDateType, not LocalDate.
LocalTimeType
import { LocalTimeType } from 'mikro-orm-js-joda'
import { LocalTimeType } from '@js-joda/core'
LocalTimeType is from mikro-orm-js-joda, not from @js-joda/core.

Defines an entity with a LocalDate property using LocalDateType and saves/loads it with MikroORM.

import { Entity, Property, PrimaryKey } from '@mikro-orm/core'; import { LocalDateType } from 'mikro-orm-js-joda'; import { LocalDate } from '@js-joda/core'; @Entity() export class Event { @PrimaryKey() id!: number; @Property({ type: LocalDateType }) date!: LocalDate; } // Usage after initializing MikroORM // const event = em.create(Event, { date: LocalDate.now() }); // await em.flush(); // const saved = await em.findOneOrFail(Event, { id: 1 }); // console.log(saved.date instanceof LocalDate); // true
Debug
Known issues
breakingPackage requires @mikro-orm/core@^6.0.5 and @js-joda/core@^5.6.1; not compatible with earlier versions.
fix
Ensure dependencies are at the minimum versions specified.
affects: >=1.0.0
gotchaLocalDateTimeType is not exported because it is platform-dependent and not supported by MikroORM's platform drivers.
fix
If you need LocalDateTime, consider storing as string or timestamp and converting manually.
affects: >=1.0.0
gotchaThe type classes must be passed as the `type` option in Property decorator; not as a generic or via `@PropertyType`.
fix
Use @Property({ type: LocalDateType }) not @Property({ type: 'localdate' }).
affects: >=1.0.0
deprecatedNo deprecations known as of version 1.1.5.
fix
N/A
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'mikro-orm-js-joda' or its corresponding type declarations.
Package not installed or tsconfig not set to allow node resolution and ESM modules.
fix
Run 'npm install mikro-orm-js-joda' and ensure tsconfig.json has "moduleResolution": "node" or "bundler".
Property 'date' does not exist on type 'Event'. Did you mean 'dateTime'?
Mismatch between property name in entity and in database query or DTO.
fix
Ensure entity property name matches the field name used in queries.
Type 'LocalDate' is not assignable to type 'string | number | Date'.
Using @Property without providing a custom type class.
fix
Add { type: LocalDateType } to the @Property decorator.
Upgrade
Version history
1.1.5latest on npm
Audit
Dependencies
@js-joda/corerequiredProvides the JS Joda types (e.g., ZonedDateTime) that are used in entity property definitions
@mikro-orm/corerequiredProvides entity and property decorators and the CustomType base class
Agent activity
4 hits · last 30 days
node
4
Resources
mikro-orm-js-joda — npm install mikro-orm-js-joda · libregistry