Add list moons command #449
2 changed files with 6 additions and 2 deletions
|
@ -5,5 +5,6 @@ CREATE TABLE `moon` (
|
||||||
`MoonNumber` int NOT NULL,
|
`MoonNumber` int NOT NULL,
|
||||||
`UserId` varchar(255) NOT NULL,
|
`UserId` varchar(255) NOT NULL,
|
||||||
`Description` varchar(255) NOT NULL
|
`Description` varchar(255) NOT NULL
|
||||||
|
`WhenArchived` datetime NULL,
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Column, Entity } from "typeorm";
|
import { Column, Entity, IsNull } from "typeorm";
|
||||||
import BaseEntity from "../../contracts/BaseEntity";
|
import BaseEntity from "../../contracts/BaseEntity";
|
||||||
import AppDataSource from "../dataSources/appDataSource";
|
import AppDataSource from "../dataSources/appDataSource";
|
||||||
|
|
||||||
|
@ -18,6 +18,9 @@ export default class Moon extends BaseEntity {
|
||||||
@Column()
|
@Column()
|
||||||
Description: string;
|
Description: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
WhenArchived?: Date;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
UserId: string;
|
UserId: string;
|
||||||
|
|
||||||
|
@ -35,7 +38,7 @@ export default class Moon extends BaseEntity {
|
||||||
const repository = AppDataSource.getRepository(Moon);
|
const repository = AppDataSource.getRepository(Moon);
|
||||||
|
|
||||||
const moons = await repository.findAndCount({
|
const moons = await repository.findAndCount({
|
||||||
where: { UserId: userId },
|
where: { UserId: userId, WhenArchived: IsNull() },
|
||||||
order: { MoonNumber: "ASC" },
|
order: { MoonNumber: "ASC" },
|
||||||
skip: rangeStart,
|
skip: rangeStart,
|
||||||
take: pageLength,
|
take: pageLength,
|
||||||
|
|
Loading…
Reference in a new issue