You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am able to get the results for the InventoryReceiptItems but I can't get the nested OrderTransactions from my InventoryReceiptLine result. I'm expecting my result to look like
Would I be better off running an addition query for each element of the array to get the nested order_transactions? or can bun do nested relations?
Bun is definitely capable of nested relations. At least it worked for me.
Simple example:
type FunctionGroupToUserRolePair struct {
Id int64 `bun:"id,pk,autoincrement"`
Role model.UserRole
UserId string `bun:"type:uuid"`
FunctionGroup *FunctionGroup `bun:"rel:belongs-to,join:function_group_id=id"`
User *User `bun:"rel:belongs-to,join:user_id=id"`
FunctionGroupId string `bun:"type:uuid"`
}
type User struct {
Id string `bun:"type:uuid,pk"`
FunctionGroups []*FunctionGroupToUserRolePair `bun:"rel:has-many"`
}
type FunctionGroup struct {
Id string `bun:"type:uuid,pk"`
Name string `bun:",unique"`
functionIds []*string `bun:",array"`
Users []*FunctionGroupToUserRolePair `bun:"rel:has-many"`
}
I'm trying to build a query that goes two objects deep using
I am able to get the results for the InventoryReceiptItems but I can't get the nested OrderTransactions from my InventoryReceiptLine result. I'm expecting my result to look like
Would I be better off running an addition query for each element of the array to get the nested order_transactions? or can bun do nested relations?
InventoryReceipt Model
InventoryReceiptLine Model
InvTran Model
The text was updated successfully, but these errors were encountered: