feat(note): save createdAt in a separate column

To keep the createdAt date stable, even when the revisions are dropped,
this adds a separate column
 to store this data separately from revisions.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-02-14 16:59:36 +01:00
parent 342efcd7b7
commit 09ec447069
4 changed files with 10 additions and 6 deletions

View file

@ -5,6 +5,7 @@
*/
import {
Column,
CreateDateColumn,
Entity,
JoinTable,
ManyToMany,
@ -94,6 +95,9 @@ export class Note {
})
version: number;
@CreateDateColumn()
createdAt: Date;
// eslint-disable-next-line @typescript-eslint/no-empty-function
private constructor() {}
@ -102,7 +106,10 @@ export class Note {
* @param owner The owner of the note
* @param alias Optional primary alias
*/
public static create(owner: User | null, alias?: string): Omit<Note, 'id'> {
public static create(
owner: User | null,
alias?: string,
): Omit<Note, 'id' | 'createdAt'> {
const newNote = new Note();
newNote.publicId = generatePublicId();
newNote.aliases = alias