This repository was archived by the owner on Nov 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Ordering of sub relations #28
Copy link
Copy link
Open
Description
Given an Order and Items relational query, how do I order the items by a field as well as the orders ?
return loader
.loadEntity(Order, "order")
.info(info)
.order({'order.date': 'DESC'})
.loadMany();
@ObjectType()
@Entity()
export class Order extends BaseEntity {
@Field((type) => Int)
@PrimaryGeneratedColumn()
id: number;
@FieldI(type) => String)
@Column()
text: string;
@Field((type) => Date)
@Column()
date: Date;
@Field((type) => [Item], { nullable: true })
@OneToMany((type) => Item, item => item.order)
items Item[];
}
@ObjectType()
@Entity()
export class Item extends BaseEntity {
@Field((type) => Int)
@PrimaryGeneratedColumn()
id: number;
@Field()
@Column()
text: string;
@Field()
@Column()
_number: number;
@Field((type) => Post)
@ManyToOne((type) => Order, (order) => order.items)
@JoinColumn({ name: 'order_id' })
item: Item;
};
I want to be able to add the equivalent to a ```.order({{'item._number': 'ASC'})``` to order items within orders by ```_number```
Metadata
Metadata
Assignees
Labels
No labels