Add list moons command #449

Merged
Vylpes merged 15 commits from feature/195-list-moons into develop 2024-08-17 16:47:14 +01:00
3 changed files with 51 additions and 0 deletions
Showing only changes of commit 50c237f6fa - Show all commits

View file

@ -0,0 +1,9 @@
CREATE TABLE `moon` (
VylpesTester marked this conversation as resolved
Review

Need to specify the primary key

Need to specify the primary key
Review

I haven't for previous migrations, is it worth still doing?

I haven't for previous migrations, is it worth still doing?
`Id` varchar(255) NOT NULL,
`WhenCreated` datetime NOT NULL,
`WhenUpdated` datetime NOT NULL,
`ServerId` varchar(255) NOT NULL,
`UserId` varchar(255) NOT NULL,
`Description` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

View file

@ -0,0 +1,27 @@
import { Column, Entity } from "typeorm";
import BaseEntity from "../../contracts/BaseEntity";
import AppDataSource from "../dataSources/appDataSource";
@Entity()
export default class Moon extends BaseEntity {
constructor(description: string, userId: string) {
super();
this.Description = description;
this.UserId = userId;
}
@Column()
Description: string;
@Column()
UserId: string;
public static async FetchMoonsByUserId(userId: string): Promise<Moon[] | null> {
const repository = AppDataSource.getRepository(Moon);
const all = await repository.find({ where: { UserId: userId } });
return all;
}
}

View file

@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import MigrationHelper from "../../../helpers/MigrationHelper"
export class CreateMoon1719856023429 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
MigrationHelper.Up('1719856023429-CreateMoon', '3.3.0', [
"01-Moon",
], queryRunner);
}
public async down(queryRunner: QueryRunner): Promise<void> {
}
}