Skip to main content
1 vote
0 answers
99 views

I have several models in my application, which have associations between each other. I'm trying to recursively upsert them, but haven't been able to find a good solution that doesn't extensively rely ...
MrArsikk's user avatar
0 votes
0 answers
38 views

I learned about gorm just a few days ago and wanted to start using it for my next project. But now I'm struggeling a bit with this: if err = gorm.G[model.User](app.DB, clause.OnConflict{ ...
Skeeve's user avatar
  • 8,652
0 votes
1 answer
60 views

i am new to go-lang and i have been using gin, gorm and postgres for backend api and i want to get the data from the model. user model: package models import "gorm.io/gorm" // enum role ...
Dev Patel's user avatar
-3 votes
2 answers
102 views

While designing social media application, i want my my users to have unique email and unique username, but the problem is, I am providing an otp verification and my table have coulmn id int primary ...
Ansal's user avatar
  • 1
1 vote
1 answer
153 views

I'm trying to create query helpers for my repository pattern. Actually I'm dealing how to add join clauses. The only idea is to inject Sprintf statement but this behavior might cause SQL injection. ...
Sevy's user avatar
  • 310
0 votes
1 answer
127 views

I know I can preload associations like this: type User struct { Name string Documents []Document } type Document struct { Name string } func loadUser() { var u User db.Preload("...
cambraca's user avatar
  • 28k
0 votes
0 answers
36 views

The below queries implements an UPSERT and works perfectly on POSTGRES if err := query.Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "finding_id"}, {Name: "...
Myles McDonnell's user avatar
0 votes
1 answer
38 views

I'm upgrading from gorm v1 to v2 and is totally confused about how I'm supposed to start a new query fresh. In v1, I can simply do db.Where("id=?", id).First(&user), which would result ...
Quan Ding's user avatar
  • 737
0 votes
1 answer
79 views

I’ve been learning GORM from the official docs, and I’m running into some confusion when trying to create records from a map using the Create() function. The official documentation shows this example ...
Amgad Deyaa's user avatar
2 votes
2 answers
257 views

I'm currently writing a query with GORM, and I need to display a pagination information with the results. In order to generate the pagination, I need the number of results that my query would return ...
Orange Lux's user avatar
  • 2,129
1 vote
1 answer
57 views

I want to create an audit log table and attach trigger for the table to tables that have an id. When I insert record into an association table which doesn't have id, it triggers the following error ...
rak1n's user avatar
  • 825
1 vote
2 answers
109 views

I have two structs in Go that look like the following: type struct UserInfo{ Name string `json:"name"` Age int `json:"age"` } type struct Profile{ ID string `json:"...
pip's user avatar
  • 37
0 votes
0 answers
22 views

I have a struct containing a map: type Config struct { ID int `gorm:"primarykey"` Class templates.Class Type string Data map[string]any `gorm:"value,type:string,...
andig's user avatar
  • 14k
1 vote
1 answer
155 views

I am using gorm as the ORM in my Go application. I am embedding gorm.Model in all my model structs. For some reason, I assumed that created_at and updated_at columns will be auto-indexed because date ...
abhisek's user avatar
  • 11
2 votes
1 answer
207 views

Although this can be done with a raw query, I would like to bulk insert a small number of records and handle upsert conflicts through the gorm Create API. I need to return the IDs of records that are ...
Anthony O's user avatar
  • 672

15 30 50 per page
1
2 3 4 5
133