metropolis/src/items/items.model.ts

35 lines
724 B
TypeScript
Raw Normal View History

2021-07-08 19:40:14 +02:00
import { Field, ID, ObjectType } from '@nestjs/graphql';
2021-07-21 23:42:11 +02:00
import { Paginated } from '../paginated.output';
2021-07-08 19:40:14 +02:00
@ObjectType('Item', {
description: 'Either the inventored thing or a box containing them',
})
export class ItemModel {
2021-07-21 01:14:20 +02:00
@Field((type) => ID, { description: 'Database ID or EAN-13 code' })
2021-07-08 19:40:14 +02:00
id: string;
2021-07-21 00:54:19 +02:00
@Field()
ean13: string;
2021-07-08 19:40:14 +02:00
@Field()
name: string;
@Field({ nullable: true })
notes?: string;
2021-07-08 23:58:07 +02:00
@Field({ nullable: true })
parent?: ItemModel;
2021-07-17 18:34:30 +02:00
2021-07-20 23:32:48 +02:00
@Field((type) => [ItemModel])
ancestors: ItemModel[];
2021-07-17 18:34:30 +02:00
@Field((type) => [ItemModel])
children: ItemModel[];
2021-07-20 00:34:15 +02:00
@Field((type) => [ItemModel])
2021-07-20 23:34:25 +02:00
descendants: ItemModel[];
2021-07-08 19:40:14 +02:00
}
2021-07-21 23:42:11 +02:00
@ObjectType()
export class PaginatedItems extends Paginated(ItemModel) {}