go gorm select uses group by and order by, and the returned data is different from the original struct type, so the returned data is useless. the following is the struct information of a table in my database, which is the service alarm information: t...
err: = db.Where ( "id =? ", id). First (& activity) .Error {"id": 30, "name": null} the name field of the database is null, but the name in & activity will become " ", how to keep it still null type Activity struct { Id ...
err: = db.Where ( "id =? ", id). First (& activity) .Error {"id": 30, "name": null} the name field of the database is null, but the name in & activity will become " ", how to keep it still null type Activity struct { Id ...
The gorm document has an update example: http: gorm.io zh_CN docs upd. db.First(&user) user.Name = "jinzhu 2" user.Age = 100 db.Save(&user) UPDATE users SET name= jinzhu 2 , age=100, birthday= 2016-01-01 , updated_at = 2...
I use golang s gorm to construct a data model. One posts, one users, one user corresponds to multiple articles posts.go . finally this problem arises, how to solve it ...
two tables, one is category, and the other is product, defined as follows: type Product struct { ProductId uint32 `gorm:"primary_key;type:int(11) unsigned auto_increment;"` Category Category `gorm:"ForeignKey:CateIDRef;"` ...
what is the default size of the gorm library for golang? what is the default size of string? Is it 255? http: gorm.io zh_CN docs mod. type:varchar(100)type:varchar(255) ...
package main import ( "database sql driver" "fmt" "time" ) type JSONTime struct { time.Time } MarshalJSON on JSONTime format Time field with %Y-%m-%d %H:%M:%S func (t JSONTime) MarshalJSON() ([]byte, er...
SQL I want to implement select * from movies left join server on movies.server_id = server.id here is my go code. I don t know what the problem is. The data of the queried server field is not correct . type Server struct { Id int64 `gor...
how does gorm create data for json fields? the official document has an example of creating a record: http: gorm.io zh_CN docs ind. db.Create(&Product{Code: "L1212", Price: 1000}) question: if this Product model has a specifi...
the frontend is pulled down and refreshed, and the backend returns 50 pieces of data at a time. I wonder if the api, written by go+gorm is correct? Please have a look at gorm: http: gorm.io zh_CN docs que.. func ListArticle(offset int) ([]*ArticleMod...
using gin+gorm, to define the model with gorm, how to generate a data table? The gorm document only states that the definition model http: gorm.io zh_CN docs mod. generates a datasheet. Do you want to use other tools? ...
problem description just used gorm for query but encountered some problems. I want to do some mixed query of and and or, but db.Where in gorm is an and query, but if you add .Or () to query, all the conditions will become or. Ask for help from the bos...
after go gorm select, the result set or all struct are returned, except that the other fields are empty the environmental background of the problems and what methods you have tried related codes db.Debug (). Where (s). Select ([] string { "id ", ...
problem description: the problem we encountered this morning has been going on all morning, but we still haven t found out what the problem is. Come to ask purpose: use gorm to modify the Boolean value of a field in the database table Code f...