mikro-orm-temporal 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/duration-type.d.ts +1 -1
- package/dist/duration-type.js +5 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/offset-date-time-type.js +1 -1
- package/dist/plain-month-day-type.d.ts +8 -0
- package/dist/plain-month-day-type.js +28 -0
- package/dist/plain-year-month-type.d.ts +8 -0
- package/dist/plain-year-month-type.js +28 -0
- package/package.json +1 -1
package/dist/duration-type.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EntityProperty, type Platform, Type } from "@mikro-orm/core";
|
|
2
2
|
export declare class DurationType extends Type<Temporal.Duration | null, string | number | null> {
|
|
3
|
-
convertToDatabaseValue(value: Temporal.Duration | null
|
|
3
|
+
convertToDatabaseValue(value: Temporal.Duration | null): string | number | null;
|
|
4
4
|
convertToJSValue(value: string | number | null, platform: Platform): Temporal.Duration | null;
|
|
5
5
|
toJSON(value: Temporal.Duration | null): string | null;
|
|
6
6
|
getColumnType(_prop: EntityProperty, platform: Platform): string;
|
package/dist/duration-type.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { Type } from "@mikro-orm/core";
|
|
2
2
|
import { isPostgres } from "./utils.js";
|
|
3
3
|
export class DurationType extends Type {
|
|
4
|
-
convertToDatabaseValue(value
|
|
4
|
+
convertToDatabaseValue(value) {
|
|
5
5
|
if (value === null) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
return value.toString();
|
|
10
|
-
}
|
|
11
|
-
return value.total({ unit: "seconds" });
|
|
8
|
+
return value.toString();
|
|
12
9
|
}
|
|
13
10
|
convertToJSValue(value, platform) {
|
|
14
11
|
/* node:coverage disable */
|
|
15
12
|
if (value === null) {
|
|
16
13
|
return null;
|
|
17
14
|
}
|
|
18
|
-
/* node:coverage enable */
|
|
19
15
|
if (typeof value === "number") {
|
|
20
16
|
return Temporal.Duration.from({ seconds: value });
|
|
21
17
|
}
|
|
18
|
+
/* node:coverage enable */
|
|
22
19
|
if (value.startsWith("P")) {
|
|
23
20
|
return Temporal.Duration.from(value);
|
|
24
21
|
}
|
|
@@ -40,7 +37,7 @@ export class DurationType extends Type {
|
|
|
40
37
|
// Postgres has a true single-purpose column type for intervals.
|
|
41
38
|
return platform.getIntervalTypeDeclarationSQL({});
|
|
42
39
|
}
|
|
43
|
-
// For all other platforms we store the duration as
|
|
44
|
-
return platform.
|
|
40
|
+
// For all other platforms we store the duration as string in ISO format.
|
|
41
|
+
return platform.getVarcharTypeDeclarationSQL({});
|
|
45
42
|
}
|
|
46
43
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ export * from "./duration-type.js";
|
|
|
2
2
|
export * from "./offset-date-time-type.js";
|
|
3
3
|
export * from "./plain-date-time-type.js";
|
|
4
4
|
export * from "./plain-date-type.js";
|
|
5
|
+
export * from "./plain-month-day-type.js";
|
|
5
6
|
export * from "./plain-time-type.js";
|
|
7
|
+
export * from "./plain-year-month-type.js";
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,6 @@ export * from "./duration-type.js";
|
|
|
2
2
|
export * from "./offset-date-time-type.js";
|
|
3
3
|
export * from "./plain-date-time-type.js";
|
|
4
4
|
export * from "./plain-date-type.js";
|
|
5
|
+
export * from "./plain-month-day-type.js";
|
|
5
6
|
export * from "./plain-time-type.js";
|
|
7
|
+
export * from "./plain-year-month-type.js";
|
|
@@ -36,7 +36,7 @@ export class OffsetDateTimeType extends Type {
|
|
|
36
36
|
/* node:coverage enable */
|
|
37
37
|
getColumnType(prop, platform) {
|
|
38
38
|
if (isMsSql(platform)) {
|
|
39
|
-
//
|
|
39
|
+
// MSSQL has a true single-purpose column type for timestamps with offset.
|
|
40
40
|
return "DATETIMEOFFSET";
|
|
41
41
|
}
|
|
42
42
|
return platform.getDateTimeTypeDeclarationSQL({ length: prop.length });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type EntityProperty, type Platform, Type } from "@mikro-orm/core";
|
|
2
|
+
export declare class PlainMonthDayType extends Type<Temporal.PlainMonthDay | null, string | null> {
|
|
3
|
+
convertToDatabaseValue(value: Temporal.PlainMonthDay | null): string | null;
|
|
4
|
+
convertToJSValue(value: string | null): Temporal.PlainMonthDay | null;
|
|
5
|
+
compareAsType(): string;
|
|
6
|
+
toJSON(value: Temporal.PlainMonthDay | null): string | null;
|
|
7
|
+
getColumnType(_prop: EntityProperty, platform: Platform): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Type } from "@mikro-orm/core";
|
|
2
|
+
export class PlainMonthDayType extends Type {
|
|
3
|
+
convertToDatabaseValue(value) {
|
|
4
|
+
if (!value) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return value.toString();
|
|
8
|
+
}
|
|
9
|
+
convertToJSValue(value) {
|
|
10
|
+
/* node:coverage disable */
|
|
11
|
+
if (!value) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
/* node:coverage enable */
|
|
15
|
+
return Temporal.PlainMonthDay.from(value);
|
|
16
|
+
}
|
|
17
|
+
compareAsType() {
|
|
18
|
+
return "string";
|
|
19
|
+
}
|
|
20
|
+
/* node:coverage disable */
|
|
21
|
+
toJSON(value) {
|
|
22
|
+
return value ? value.toString() : null;
|
|
23
|
+
}
|
|
24
|
+
/* node:coverage enable */
|
|
25
|
+
getColumnType(_prop, platform) {
|
|
26
|
+
return platform.getCharTypeDeclarationSQL({ length: 5 });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type EntityProperty, type Platform, Type } from "@mikro-orm/core";
|
|
2
|
+
export declare class PlainYearMonthType extends Type<Temporal.PlainYearMonth | null, string | null> {
|
|
3
|
+
convertToDatabaseValue(value: Temporal.PlainYearMonth | null): string | null;
|
|
4
|
+
convertToJSValue(value: string | null): Temporal.PlainYearMonth | null;
|
|
5
|
+
compareAsType(): string;
|
|
6
|
+
toJSON(value: Temporal.PlainYearMonth | null): string | null;
|
|
7
|
+
getColumnType(_prop: EntityProperty, platform: Platform): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Type } from "@mikro-orm/core";
|
|
2
|
+
export class PlainYearMonthType extends Type {
|
|
3
|
+
convertToDatabaseValue(value) {
|
|
4
|
+
if (!value) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return value.toString();
|
|
8
|
+
}
|
|
9
|
+
convertToJSValue(value) {
|
|
10
|
+
/* node:coverage disable */
|
|
11
|
+
if (!value) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
/* node:coverage enable */
|
|
15
|
+
return Temporal.PlainYearMonth.from(value);
|
|
16
|
+
}
|
|
17
|
+
compareAsType() {
|
|
18
|
+
return "string";
|
|
19
|
+
}
|
|
20
|
+
/* node:coverage disable */
|
|
21
|
+
toJSON(value) {
|
|
22
|
+
return value ? value.toString() : null;
|
|
23
|
+
}
|
|
24
|
+
/* node:coverage enable */
|
|
25
|
+
getColumnType(_prop, platform) {
|
|
26
|
+
return platform.getCharTypeDeclarationSQL({ length: 7 });
|
|
27
|
+
}
|
|
28
|
+
}
|