metropolis/src/items/items.model.ts

35 lines
724 B
TypeScript

import { Field, ID, ObjectType } from '@nestjs/graphql';
import { Paginated } from '../paginated.output';
@ObjectType('Item', {
description: 'Either the inventored thing or a box containing them',
})
export class ItemModel {
@Field((type) => ID, { description: 'Database ID or EAN-13 code' })
id: string;
@Field()
ean13: string;
@Field()
name: string;
@Field({ nullable: true })
notes?: string;
@Field({ nullable: true })
parent?: ItemModel;
@Field((type) => [ItemModel])
ancestors: ItemModel[];
@Field((type) => [ItemModel])
children: ItemModel[];
@Field((type) => [ItemModel])
descendants: ItemModel[];
}
@ObjectType()
export class PaginatedItems extends Paginated(ItemModel) {}