Add model relationship on new record

I have a situation where I need to specify a one to many relationship between “order” and “order_item”. I want to set the order items on the order before the order is saved in the database. Is this possible? I’m guessing this is not possible becuase the order_items need to order id for the relationship. Has anyone else run into this issue before?

the only way would be to use a custom key for the relation like externalId… so you assign a unique key to the order and to the items