0
這是我第一天使用GRPC和我有幾個問題:GRPC。如何創建關聯?
說我有產生時,看起來像這樣一個GRPC順序:
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "something.Order" do
optional :uuid, :string, 1
repeated :shipments, :message, 2, "something.Shipment"
...
end
end
因此,一個Order
有許多shipments
。當我創建訂單作爲服務中的回覆發送時......我如何創建多件貨件?
可我只是做:
order = Order.find(request.id)
Something::Order.new(uuid: order.id, shipments: [order.shipments)
或是否它需要:
order = Order.find(request.id)
Something::Order.new(uuid: order.id, shipments: [order.shipments.attributes)
我得到後者從these docs