go-gorm / gorm.io

GORM official site

Home Page:https://gorm.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gorm Relationships ManyToMany?

EliuDedupely opened this issue · comments

Document Link

Trying to establish a relationship of User and Accounts for Many To Many. Not working

`2023/01/07 22:49:25 ←[32mC:/Go/src/goapi/model/account.go:57
←[0m←[33m[2.170ms] ←[34;1m[rows:1]←[0m INSERT INTO "user_accounts" ("account_id","user_id") VALUES (1,1) ON CONFLICT DO NOTHING

2023/01/07 22:49:25 ←[32mC:/Go/src/goapi/model/account.go:57
←[0m←[33m[9.190ms] ←[34;1m[rows:1]←[0m INSERT INTO "accounts" ("created_at","updated_at","deleted_at","name") VALUES ('2023-01-07 22:49:25.3','2023-01-07 22:49:25.3',NULL,'iDev') RETURNING "id","name"
[GIN] 2023/01/07 - 22:49:25 |←[97;42m 201 ←[0m| 12.207ms | |←[97;46m POST ←[0m "/api/v1/accounts"
response-http: &{201 map[Content-Type:[application/json; charset=utf-8]] {"success":true} false map[Content-Type:[application/json; charset=utf-8]] true}

response-map: map[success:]
----`

Your Question

Expected answer

Could you please provide models code?

Could you please provide models code?

you solve it. It was an error in my code and how to formulate the relationships more than anything in Go.