Comments (6)
Actually, there already have constant relationship here, and doc is here :
gen.FieldRelateModel(field.HasMany, "CreditCards", model.CreditCard{}, nil)
Besides, maybe you can describe more clearly what kind of simplification you want.
from gen.
- Just want to include the model which not from GORM, maybe from mongodb、es.
The above example, I claim&field.RelateConfig{GORMTag: "-"}
- There is no
field.Has
https://github.com/go-gorm/gen/blob/master/field/association.go#L14-L17
https://github.com/go-gorm/gorm/blob/master/schema/relationship.go#L20 - Hope there is an option to mark gorm tag useless like the example above
from gen.
OK, got it. The option FieldRelateModel
is designed for relationship which can recognized by GORM, which means if you want to add new field in generated model struct which relate to exist struct in your project you should use option FieldNew
, ex:
gen.FieldNew("A", "model.A", "")
from gen.
gen.FieldNew("A", "model.A", `gorm:"-"`)
The way worked the same as the above example.
But still need to claim fieldTag to disable gorm work, can you provide a way to quickly disable it?
from gen.
Actually, the tag gorm:"-"
is an additional tag for field your want to build, so we expect it has to be set on your own. And in my opinion, the code gen.FieldNew("A", "model.A", `gorm:"-"`)
is concise enough, create another option like gen.FieldNewDisableGORM("A", "model.A")
is not necessary.
If you have some reason i don't know can prove the necessity of adding this option, plz let me know.
from gen.
That's not much of a reason, just except that there is an option to disable gorm.
It's not too much of a problem for me to be able to customize this
from gen.
Related Issues (20)
- Order By 无法执行自定义排序
- GEN Generate unique aware unit tests.
- The return value Count of the FindByPage function is always 0.
- 从sqlserver数据库将numeric字段逆向生成uint8
- gentools install broke yesterday - go install gorm.io/gen/tools/gentool@latest fails HOT 11
- 在使用 GenerateModel 时,总是将字段中的 ssh 转换为 SSH,想要转换为 Ssh HOT 1
- Gentool generates invalid tags on Postgres SERIAL PRIMARY KEY column
- Query generation with existing database table named "fields"
- 使用动态sql生成的方法,Preload加载关联的关系失败
- embed custom model for generated model
- Is there a way to add `db` tag HOT 1
- How to keep model name 's' prefix? HOT 1
- gorm Gen Tool int32
- Same table names cannot be generated across different schemes HOT 1
- left join 时候对关联表软删除数据没做where过滤
- 如何不重复生成query/gen.go
- 使用joins+select,gen与gorm执行的sql效果不一致
- How to sort on a foreign key constraint's column count?
- @@Table: Annotations are not dynamic
- 当在数据库中申明default为NULL时,通过gen生成的代码好像不会加上这个tag
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gen.