环回4 hasMany具有复合外键(postgres)

时间:2019-10-30 05:56:05

标签: loopback4

为简单起见,我有一个客户1-*订单

Create table customers (
customer_id int,
offset_id int,
name text,
CONSTRAINT pk_customer_id PRIMARY KEY ( customer_id, offset_id )) 

Create table orders (
id int,
offset_id int,
name text,
customer_id int,
CONSTRAINT pk_order_id PRIMARY KEY ( id, offset_id ),
CONSTRAINT fk_orders_customerid FOREIGN KEY (customer_id, offset_id ) REFERENCES customer (customer_id, offset_id)

有什么办法可以将订单引入客户模型?

1 个答案:

答案 0 :(得分:0)

请参阅:

How to create loopback 4 model, repository and controller without specifying an ID

总结:Loopback4根据文档说明不支持组合键。