This repository has been archived by the owner on May 18, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeongho Nam
committed
Aug 25, 2022
1 parent
74056bd
commit 326935d
Showing
8 changed files
with
92 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ node_modules/ | |
src/ | ||
lib/test/ | ||
|
||
*.js.map | ||
*.*ignore | ||
package-lock.json | ||
tsconfig.api.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ColumnOptions, CreateDateColumn } from "typeorm"; | ||
|
||
/** | ||
* Creation timstamp column for `postgres`. | ||
* | ||
* When defining datetime column, time zone is very important when considering global | ||
* service. However, default `CreateDateColumn` of `typeorm` does not archive the time zone | ||
* when using `postgres` database. Furthermore, `typeorm` does not archive milliseconds. | ||
* | ||
* I think it's a critical mistake of `typeorm`, but they think it's not a bug but spec. | ||
* | ||
* Therefore, `safe-typeorm` supports custom creation timestamp column which supports time | ||
* zone and milliseconds. When using `postgres` database, use this `CreateTimestampColumn` | ||
* instead of the `CreateDateColumn`. | ||
* | ||
* @param options Additional options if required | ||
* @returns Property decorator function | ||
*/ | ||
export const CreateTimestampColumn = (options?: ColumnOptions) => | ||
CreateDateColumn({ | ||
...(options || {}), | ||
precision: 3, | ||
type: "timestamp with time zone", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ColumnOptions, DeleteDateColumn } from "typeorm"; | ||
|
||
/** | ||
* Deletion timstamp column for `postgres`. | ||
* | ||
* When defining datetime column, time zone is very important when considering global | ||
* service. However, default `DeleteDateColumn` of `typeorm` does not archive the time zone | ||
* when using `postgres` database. Furthermore, `typeorm` does not archive milliseconds. | ||
* | ||
* I think it's a critical mistake of `typeorm`, but they think it's not a bug but spec. | ||
* | ||
* Therefore, `safe-typeorm` supports custom deletion timestamp column which supports time | ||
* zone and milliseconds. When using `postgres` database, use this `DeleteTimestampColumn` | ||
* instead of the `DeleteDateColumn`. | ||
* | ||
* @param options Additional options if required | ||
* @returns Property decorator function | ||
*/ | ||
export const DeleteTimestampColumn = (options?: ColumnOptions) => | ||
DeleteDateColumn({ | ||
...(options || {}), | ||
precision: 3, | ||
type: "timestamp with time zone", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Column } from "typeorm"; | ||
import { ColumnCommonOptions } from "typeorm/decorator/options/ColumnCommonOptions"; | ||
import { ColumnNumericOptions } from "typeorm/decorator/options/ColumnNumericOptions"; | ||
|
||
export const TimestampColumn = ( | ||
options?: ColumnCommonOptions & Omit<ColumnNumericOptions, "precision">, | ||
) => | ||
Column("timestamp with time zone", { | ||
...(options || {}), | ||
precision: 3, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ColumnOptions, UpdateDateColumn } from "typeorm"; | ||
|
||
/** | ||
* Update timstamp column for `postgres`. | ||
* | ||
* When defining datetime column, time zone is very important when considering global | ||
* service. However, default `UpdateDateColumn` of `typeorm` does not archive the time zone | ||
* when using `postgres` database. Furthermore, `typeorm` does not archive milliseconds. | ||
* | ||
* I think it's a critical mistake of `typeorm`, but they think it's not a bug but spec. | ||
* | ||
* Therefore, `safe-typeorm` supports custom update timestamp column which supports time | ||
* zone and milliseconds. When using `postgres` database, use this `UpdateTimestampColumn` | ||
* instead of the `UpdateDateColumn`. | ||
* | ||
* @param options Additional options if required | ||
* @returns Property decorator function | ||
*/ | ||
export const UpdateTimestampColumn = (options?: ColumnOptions) => | ||
UpdateDateColumn({ | ||
...(options || {}), | ||
precision: 3, | ||
type: "timestamp with time zone", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
export * from "./Belongs"; | ||
export * from "./EncryptedColumn"; | ||
export * from "./Has"; | ||
export * from "./Has"; | ||
|
||
export * from "./CreateTimestampColumn"; | ||
export * from "./DeleteTimestampColumn"; | ||
export * from "./TimestampColumn"; | ||
export * from "./UpdateTimestampColumn"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters